Dmitry Timoshkov : user32: Add a test for CreateWindow/
DestroyWindow behaviour with WS_CHILD | WS_POPUP style,
make it pass under Wine.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Oct 31 05:43:04 CST 2006
Module: wine
Branch: master
Commit: 5b43d41a2b6429384930ab3ac3e152d42a13160b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5b43d41a2b6429384930ab3ac3e152d42a13160b
Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Mon Oct 30 16:41:24 2006 +0800
user32: Add a test for CreateWindow/DestroyWindow behaviour with WS_CHILD | WS_POPUP style, make it pass under Wine.
---
dlls/user/tests/win.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++--
dlls/user/win.c | 7 ++--
2 files changed, 77 insertions(+), 7 deletions(-)
diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c
index 9d8ae6c..6821832 100644
--- a/dlls/user/tests/win.c
+++ b/dlls/user/tests/win.c
@@ -3712,6 +3712,7 @@ #define expect_ex_style(window, ex_style
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 @@ #define expect_ex_style(window, ex_style
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 @@ #define expect_ex_style(window, ex_style
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 @@ #define expect_ex_style(window, ex_style
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 --git a/dlls/user/win.c b/dlls/user/win.c
index 6eac41c..d355a13 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -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-cvs
mailing list