Add a test for CreateWindow/DestroyWindow behaviour with WS_CHILD |
WS_POPUP style, make it pass under Wine
Dmitry Timoshkov
dmitry at codeweavers.com
Mon Oct 30 02:41:24 CST 2006
Hello,
Changelog:
Add a test for CreateWindow/DestroyWindow behaviour with
WS_CHILD | WS_POPUP style, make it pass under Wine.
diff -up cvs/hq/wine/dlls/user/tests/win.c wine/dlls/user/tests/win.c
--- cvs/hq/wine/dlls/user/tests/win.c 2006-10-10 20:00:55.000000000 +0900
+++ wine/dlls/user/tests/win.c 2006-10-30 16:27:23.000000000 +0800
@@ -3712,6 +3712,7 @@ static void test_CreateWindow(void)
SetLastError(0xdeadbeef);
ok(IsMenu(hmenu), "IsMenu error %d\n", GetLastError());
+ /* WS_CHILD */
SetLastError(0xdeadbeef);
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD,
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
@@ -3748,6 +3749,7 @@ static void test_CreateWindow(void)
expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
DestroyWindow(hwnd);
+ /* WS_POPUP */
SetLastError(0xdeadbeef);
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP,
0, 0, 100, 100, parent, hmenu, 0, NULL);
@@ -3777,12 +3779,12 @@ static void test_CreateWindow(void)
hmenu = CreateMenu();
assert(hmenu != 0);
SetLastError(0xdeadbeef);
- hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP,
+ hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP,
0, 0, 100, 100, parent, hmenu, 0, NULL);
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
expect_menu(hwnd, hmenu);
expect_style(hwnd, WS_POPUP | WS_CLIPSIBLINGS);
- expect_ex_style(hwnd, WS_EX_APPWINDOW);
+ expect_ex_style(hwnd, 0);
DestroyWindow(hwnd);
SetLastError(0xdeadbeef);
ok(!IsMenu(hmenu), "IsMenu should fail\n");
@@ -3802,20 +3804,87 @@ static void test_CreateWindow(void)
ok(!IsMenu(hmenu), "IsMenu should fail\n");
ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+ /* WS_CHILD | WS_POPUP */
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP,
+ 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+ ok(!hwnd, "CreateWindowEx should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
hmenu = CreateMenu();
assert(hmenu != 0);
SetLastError(0xdeadbeef);
- hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP,
+ hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP,
0, 0, 100, 100, parent, hmenu, 0, NULL);
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
expect_menu(hwnd, hmenu);
- expect_style(hwnd, WS_POPUP | WS_CLIPSIBLINGS);
+ expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CLIPSIBLINGS);
+ expect_ex_style(hwnd, WS_EX_APPWINDOW);
+ DestroyWindow(hwnd);
+ SetLastError(0xdeadbeef);
+ ok(!IsMenu(hmenu), "IsMenu should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
+ 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+ ok(!hwnd, "CreateWindowEx should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
+ hmenu = CreateMenu();
+ assert(hmenu != 0);
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
+ 0, 0, 100, 100, parent, hmenu, 0, NULL);
+ ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
+ expect_menu(hwnd, hmenu);
+ expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS);
+ expect_ex_style(hwnd, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
+ DestroyWindow(hwnd);
+ SetLastError(0xdeadbeef);
+ ok(!IsMenu(hmenu), "IsMenu should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP,
+ 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+ ok(!hwnd, "CreateWindowEx should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
+ hmenu = CreateMenu();
+ assert(hmenu != 0);
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP,
+ 0, 0, 100, 100, parent, hmenu, 0, NULL);
+ ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
+ expect_menu(hwnd, hmenu);
+ expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CLIPSIBLINGS);
expect_ex_style(hwnd, 0);
DestroyWindow(hwnd);
SetLastError(0xdeadbeef);
ok(!IsMenu(hmenu), "IsMenu should fail\n");
ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
+ 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+ ok(!hwnd, "CreateWindowEx should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
+ hmenu = CreateMenu();
+ assert(hmenu != 0);
+ SetLastError(0xdeadbeef);
+ hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
+ 0, 0, 100, 100, parent, hmenu, 0, NULL);
+ ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
+ expect_menu(hwnd, hmenu);
+ expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS);
+ expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
+ DestroyWindow(hwnd);
+ SetLastError(0xdeadbeef);
+ ok(!IsMenu(hmenu), "IsMenu should fail\n");
+ ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
+
#undef expect_menu
#undef expect_style
#undef expect_ex_style
diff -up cvs/hq/wine/dlls/user/win.c wine/dlls/user/win.c
--- cvs/hq/wine/dlls/user/win.c 2006-10-27 16:20:25.000000000 +0900
+++ wine/dlls/user/win.c 2006-10-30 16:32:45.000000000 +0800
@@ -626,7 +626,8 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
/* free resources associated with the window */
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
- if (!(wndPtr->dwStyle & WS_CHILD)) menu = (HMENU)wndPtr->wIDmenu;
+ if ((wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD)
+ menu = (HMENU)wndPtr->wIDmenu;
sys_menu = wndPtr->hSysMenu;
WIN_ReleasePtr( wndPtr );
@@ -1012,7 +1013,7 @@ static HWND WIN_CreateWindowEx( CREATEST
* It affects only the style loaded into the WIN structure.
*/
- if (!(wndPtr->dwStyle & WS_CHILD))
+ if ((wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD)
{
wndPtr->dwStyle |= WS_CLIPSIBLINGS;
if (!(wndPtr->dwStyle & WS_POPUP))
@@ -1048,7 +1049,7 @@ static HWND WIN_CreateWindowEx( CREATEST
/* Set the window menu */
- if (!(wndPtr->dwStyle & WS_CHILD))
+ if ((wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD)
{
if (cs->hMenu)
{
More information about the wine-patches
mailing list