Dmitry Timoshkov : user: Neither WS_CAPTION nor WS_EX_APPWINDOW has anything to do how

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 9 11:16:44 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 2dd2eafd3c6228da2574cc3a09bf1e5b9d7b83dc
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=2dd2eafd3c6228da2574cc3a09bf1e5b9d7b83dc

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Fri Jun  9 23:13:50 2006 +0900

user: Neither WS_CAPTION nor WS_EX_APPWINDOW has anything to do how
passed in to CreateWindow menu should be handled.

---

 dlls/user/menu.c      |    8 +++
 dlls/user/tests/win.c |  133 +++++++++++++++++++++++++++++++++++++++++++++++++
 dlls/user/win.c       |    3 -
 3 files changed, 141 insertions(+), 3 deletions(-)

diff --git a/dlls/user/menu.c b/dlls/user/menu.c
index 4b10e7f..83e55d9 100644
--- a/dlls/user/menu.c
+++ b/dlls/user/menu.c
@@ -4337,7 +4337,13 @@ HMENU WINAPI LoadMenuIndirectA( LPCVOID 
 BOOL WINAPI IsMenu(HMENU hmenu)
 {
     LPPOPUPMENU menu = MENU_GetMenu(hmenu);
-    return menu != NULL;
+
+    if (!menu)
+    {
+        SetLastError(ERROR_INVALID_MENU_HANDLE);
+        return FALSE;
+    }
+    return TRUE;
 }
 
 /**********************************************************************
diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c
index 7adfa35..f291fff 100644
--- a/dlls/user/tests/win.c
+++ b/dlls/user/tests/win.c
@@ -3604,6 +3604,138 @@ static void test_IsWindowUnicode(void)
     DestroyWindow(hwnd);
 }
 
+static void test_CreateWindow(void)
+{
+    HWND hwnd, parent;
+    HMENU hmenu;
+
+#define expect_menu(window, menu) \
+    SetLastError(0xdeadbeef); \
+    ok(GetMenu(window) == (HMENU)menu, "GetMenu error %ld\n", GetLastError())
+
+#define expect_style(window, style)\
+    ok(GetWindowLong(window, GWL_STYLE) == (style), "expected style %lx != %lx\n", (long)(style), GetWindowLong(window, GWL_STYLE))
+
+#define expect_ex_style(window, ex_style)\
+    ok(GetWindowLong(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %lx != %lx\n", (long)(ex_style), GetWindowLong(window, GWL_EXSTYLE))
+
+    hmenu = CreateMenu();
+    assert(hmenu != 0);
+    parent = GetDesktopWindow();
+    assert(parent != 0);
+
+    SetLastError(0xdeadbeef);
+    ok(IsMenu(hmenu), "IsMenu error %ld\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD,
+                           0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, 1);
+    expect_style(hwnd, WS_CHILD);
+    expect_ex_style(hwnd, WS_EX_APPWINDOW);
+    DestroyWindow(hwnd);
+
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_CAPTION,
+                           0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, 1);
+    expect_style(hwnd, WS_CHILD | WS_CAPTION);
+    expect_ex_style(hwnd, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
+    DestroyWindow(hwnd);
+
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD,
+                           0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, 1);
+    expect_style(hwnd, WS_CHILD);
+    expect_ex_style(hwnd, 0);
+    DestroyWindow(hwnd);
+
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_CAPTION,
+                           0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, 1);
+    expect_style(hwnd, WS_CHILD | WS_CAPTION);
+    expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
+    DestroyWindow(hwnd);
+
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP,
+                           0, 0, 100, 100, parent, hmenu, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, hmenu);
+    expect_style(hwnd, 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 %ld\n", GetLastError());
+
+    hmenu = CreateMenu();
+    assert(hmenu != 0);
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP | WS_CAPTION,
+                           0, 0, 100, 100, parent, hmenu, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, hmenu);
+    expect_style(hwnd, 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 %ld\n", GetLastError());
+
+    hmenu = CreateMenu();
+    assert(hmenu != 0);
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP,
+                           0, 0, 100, 100, parent, hmenu, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, hmenu);
+    expect_style(hwnd, 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 %ld\n", GetLastError());
+
+    hmenu = CreateMenu();
+    assert(hmenu != 0);
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP | WS_CAPTION,
+                           0, 0, 100, 100, parent, hmenu, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, hmenu);
+    expect_style(hwnd, 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 %ld\n", GetLastError());
+
+    hmenu = CreateMenu();
+    assert(hmenu != 0);
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP,
+                           0, 0, 100, 100, parent, hmenu, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
+    expect_menu(hwnd, hmenu);
+    expect_style(hwnd, 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 %ld\n", GetLastError());
+
+#undef expect_menu
+#undef expect_style
+#undef expect_ex_style
+}
+
 START_TEST(win)
 {
     pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -3651,6 +3783,7 @@ START_TEST(win)
     test_capture_2();
     test_capture_3(hwndMain, hwndMain2);
 
+    test_CreateWindow();
     test_parent_owner();
     test_SetParent();
     test_shell_window();
diff --git a/dlls/user/win.c b/dlls/user/win.c
index 3d5fecb..593fef1 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -1037,8 +1037,7 @@ static HWND WIN_CreateWindowEx( CREATEST
 
     /* Set the window menu */
 
-    if (((wndPtr->dwStyle & (WS_CAPTION|WS_CHILD)) == WS_CAPTION) ||
-        (wndPtr->dwExStyle & WS_EX_APPWINDOW))
+    if (!(wndPtr->dwStyle & WS_CHILD))
     {
         if (cs->hMenu)
         {




More information about the wine-cvs mailing list