我正在尝试学习如何使顶级 Win32 窗口成为另一个窗口的子窗口。
当我更改窗口的父级时,我仍然会得到难看的圆角,就好像它是一个带有圆形标题栏的顶级窗口一样。为什么?我该如何解决这个问题?(我无法WM_UPDATEUISTATE
提供帮助,但我也不确定如何正确使用它。)
#include <tchar.h>
#include <windows.h>
#include <commctrl.h>
int _tmain()
{
WNDCLASS wndClass = {
0, &DefWindowProc, 0, 0, NULL, NULL, LoadCursor(NULL, IDC_ARROW),
GetSysColorBrush(COLOR_3DFACE), NULL, TEXT("MyWindowClass")
};
ATOM atom = RegisterClass(&wndClass);
HWND hWnd = CreateWindow(MAKEINTATOM(atom), TEXT("Win"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
HWND hWndChild = CreateWindowEx(WS_EX_CLIENTEDGE,
WC_EDIT, TEXT("Control"), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10, 10, 86, 24, NULL, NULL, NULL, NULL);
SetParent(hWndChild, hWnd); // Change the parent
SetWindowLong(hWndChild, GWL_STYLE, // Set child styles
GetWindowLong(hWndChild, GWL_STYLE)
& ~(WS_OVERLAPPED | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
| WS_CHILDWINDOW);
SetWindowPos(hWndChild, NULL, 0, 0, 0, 0, // Refresh
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE
| SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_FRAMECHANGED);
BOOL bRet;
MSG msg;
while ((bRet = GetMessage(&msg, hWnd, 0, 0)) != 0 && bRet != -1)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}