user32: Add a test for CreateWindow/DestroyWindow behaviour with WS_CHILD | WS_POPUP style, make it pass under Wine.

This commit is contained in:
Dmitry Timoshkov 2006-10-30 16:41:24 +08:00 committed by Alexandre Julliard
parent c8da5149d0
commit 5b43d41a2b
2 changed files with 77 additions and 7 deletions
dlls/user

View File

@ -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

View File

@ -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( CREATESTRUCTA *cs, ATOM classAtom, UINT flags )
* 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( CREATESTRUCTA *cs, ATOM classAtom, UINT flags )
/* Set the window menu */
if (!(wndPtr->dwStyle & WS_CHILD))
if ((wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD)
{
if (cs->hMenu)
{