2

我将第 3 方应用程序嵌入到 C# Windows 窗体上的面板中(使用SetParent来自 user32.dll)。然后我需要关闭标题栏窗口样式WS_CAPTION,使其看起来像托管应用程序的一部分。

如何更改窗口的样式以实现此目的?

例如,说_hWnd是要嵌入的应用程序的句柄。

4

4 回答 4

3

如果没有记错,您可以对样式执行 GetWindowLong,对该值执行 |= ~ WS_CAPTION,然后执行 SetWindowLong。请参阅 MSDN 中的那些 API。

另见: http ://www.codeguru.com/forum/showthread.php?t=352963

于 2009-09-13T07:40:02.473 回答
2

SetWindowLong (_hWnd, GWL_STYLE, GetWindowLong (_hWnd, GWL_STYLE) & ~WS_CAPTION);

于 2009-09-13T07:44:28.877 回答
2

看看WindowInterceptor

于 2009-09-13T07:48:04.563 回答
0

使用GetWindowLong检索窗口样式,屏蔽WS_CAPTION位,然后使用SetWindowLong设置更新的样式:

var style = GetWindowLong(_hWnd, GWL_STYLE);
SetWindowLong(_hWnd, GWL_STYLE, style & ~WS_CAPTION);

并使用以下帮助代码:

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);
于 2013-04-22T09:08:54.680 回答