[英]Access Windows.Form of Unity standalone player for windows
Windows 的統一獨立播放器是Windows.Form
嗎? 如果是這樣,我們如何訪問它的句柄?
if(Form.ActiveForm != null)
{
m_form = Form.ActiveForm;
Debug.Log("m_form.Name");
}
我正在使用Mono
版本的System.Windows.Forms.dll
I am trying the above code to access the Form
handle but it always returns null
even when window is active, which makes me doubt that standalone windows build is not a Windows.Form
.
我基本上需要訪問工具欄以便我可以更改它的顏色(不是標題,對於標題,我們已經有一個不需要訪問Form
實例的解決方法)。 另外,我需要為 window 設置最小尺寸。 任何解決方案都會有所幫助。
您始終可以 p/invoke winapi,因此為了獲取當前活動 window 的句柄,請使用以下命令:
[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();
為了移動/調整 window 的 position,您可以使用以下其中一種:
SetWindowPos 、 MoveWindow和AdjustWindowRectEx
順便說一句,得到一個窗口的句柄..
[DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
或者:
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.