[英]Access Windows.Form of Unity standalone player for windows
Is unity standalone player for Windows a Windows.Form
? Windows 的统一独立播放器是
Windows.Form
吗? If so, how can we access its handle?如果是这样,我们如何访问它的句柄?
if(Form.ActiveForm != null)
{
m_form = Form.ActiveForm;
Debug.Log("m_form.Name");
}
I am using the Mono
version of System.Windows.Forms.dll
.我正在使用
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
. 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
.
I basically need to access the toolbar so that I can change its color (Not title, for title we already have a workaround that doesn't require accessing the Form
instance).我基本上需要访问工具栏以便我可以更改它的颜色(不是标题,对于标题,我们已经有一个不需要访问
Form
实例的解决方法)。 Also, I need to set minimum size for the window.另外,我需要为 window 设置最小尺寸。 Any solution will be helpful.
任何解决方案都会有所帮助。
You can always p/invoke winapi, so in order to get the handle of the current active window use this:您始终可以 p/invoke winapi,因此为了获取当前活动 window 的句柄,请使用以下命令:
[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();
And in order to move / adjust the position of the window u can use one of these:为了移动/调整 window 的 position,您可以使用以下其中一种:
SetWindowPos , MoveWindow and AdjustWindowRectEx SetWindowPos 、 MoveWindow和AdjustWindowRectEx
and btw to get a the window's handle..顺便说一句,得到一个窗口的句柄..
[DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
or:或者:
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.