C# 如何关闭窗口的WS_标题样式(使用user32.dll)?
我正在将第三方应用程序嵌入C#Windows窗体上的面板中(使用user32.dll中的C# 如何关闭窗口的WS_标题样式(使用user32.dll)?,c#,user32,C#,User32,我正在将第三方应用程序嵌入C#Windows窗体上的面板中(使用user32.dll中的SetParent)。然后我需要关闭标题栏窗口样式WS\u CAPTION,使其看起来像宿主应用程序的一部分 如何更改窗口的样式以实现此目的 例如,假设\u hWnd是要嵌入的应用程序的句柄。如果内存可用,您可以对样式执行GetWindowLong,对该值执行|=~WS\u CAPTION,然后设置WindowLong。请参阅MSDN中的这些API 另请参见:(\u-hWnd,GWL\u样式,(\u-hWnd
SetParent
)。然后我需要关闭标题栏窗口样式WS\u CAPTION
,使其看起来像宿主应用程序的一部分
如何更改窗口的样式以实现此目的
例如,假设
\u hWnd
是要嵌入的应用程序的句柄。如果内存可用,您可以对样式执行GetWindowLong,对该值执行|=~WS\u CAPTION,然后设置WindowLong。请参阅MSDN中的这些API
另请参见:(\u-hWnd,GWL\u样式,(\u-hWnd,GWL\u样式)和~WS\u标题) 查看用于检索窗口样式,屏蔽WS\u标题
位,然后使用以下命令设置更新的样式:
并具有以下帮助程序代码:
const int GWL_STYLE = -16;
const int WS_CAPTION = 0x00C00000;
[DllImport ("user32")]
private static extern int GetWindowLong(System.IntPtr hwnd, int nIndex);
[DllImport ("user32")]
private static extern int SetWindowLong(System.IntPtr hwnd, int index, int newLong);
const int GWL_STYLE = -16;
const int WS_CAPTION = 0x00C00000;
[DllImport ("user32")]
private static extern int GetWindowLong(System.IntPtr hwnd, int nIndex);
[DllImport ("user32")]
private static extern int SetWindowLong(System.IntPtr hwnd, int index, int newLong);