user32: Add a test for CreateWindow/DestroyWindow behaviour with WS_CHILD | WS_POPUP style, make it pass under Wine.
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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     /* 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 @@
      * 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 @@
 
     /* Set the window menu */
 
-    if (!(wndPtr->dwStyle & WS_CHILD))
+    if ((wndPtr->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD)
     {
         if (cs->hMenu)
         {