Add a test case and a fix for the window styles state at the window
authorDmitry Timoshkov <dmitry@codeweavers.com>
Fri, 6 Feb 2004 05:18:56 +0000 (05:18 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 6 Feb 2004 05:18:56 +0000 (05:18 +0000)
creation time.

dlls/user/tests/win.c
windows/win.c

index 0757d285a6d4f730ad4080dc2bb8e87b6b83948e..1ee400d6da5c03646ec06b9e11effdf295e376d1 100644 (file)
@@ -556,10 +556,17 @@ static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
     {
        case HCBT_CREATEWND:
        {
+           DWORD style;
            CBT_CREATEWNDA *createwnd = (CBT_CREATEWNDA *)lParam;
            trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08lx\n",
                  (HWND)wParam, createwnd->lpcs->hwndParent, createwnd->lpcs->style);
            ok(createwnd->hwndInsertAfter == HWND_TOP, "hwndInsertAfter should be always HWND_TOP\n");
+
+           /* WS_VISIBLE should be turned off yet */
+           style = createwnd->lpcs->style & ~WS_VISIBLE;
+           ok(style == GetWindowLongA((HWND)wParam, GWL_STYLE),
+               "style of hwnd and style in the CREATESTRUCT do not match: %08lx != %08lx\n",
+               GetWindowLongA((HWND)wParam, GWL_STYLE), style);
            break;
        }
     }
index 0a73819308aebe312bf3d3679803ebaf20df36ba..cd7e2b545f4be672929d6fae3f1560784f6167a9 100644 (file)
@@ -1105,10 +1105,10 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
 
     WIN_FixCoordinates(cs, &sw); /* fix default coordinates */
 
-    /* Correct the window style - stage 1
+    /* Correct the window styles.
      *
-     * These are patches that appear to affect both the style loaded into the
-     * WIN structure and passed in the CreateStruct to the WM_CREATE etc.
+     * It affects both the style loaded into the WIN structure and
+     * passed in the CREATESTRUCT to the WM_[NC]CREATE.
      *
      * WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so
      * why does the user get to set it?
@@ -1124,6 +1124,13 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
     else
         cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
 
+    if (!(cs->style & WS_CHILD))
+    {
+        cs->style |= WS_CLIPSIBLINGS;
+        if (!(cs->style & WS_POPUP))
+            cs->style |= WS_CAPTION;
+    }
+
     /* Create the window structure */
 
     if (!(wndPtr = create_window_handle( parent, owner, classAtom, cs->hInstance, type )))
@@ -1154,17 +1161,9 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
     wndPtr->hIconSmall     = 0;
     wndPtr->hSysMenu       = (wndPtr->dwStyle & WS_SYSMENU) ? MENU_GetSysMenu( hwnd, 0 ) : 0;
 
-    /* Correct the window style - stage 2 */
+    if (!(cs->style & (WS_CHILD | WS_POPUP)))
+        wndPtr->flags |= WIN_NEED_SIZE;
 
-    if (!(cs->style & WS_CHILD))
-    {
-       wndPtr->dwStyle |= WS_CLIPSIBLINGS;
-       if (!(cs->style & WS_POPUP))
-       {
-            wndPtr->dwStyle |= WS_CAPTION;
-            wndPtr->flags |= WIN_NEED_SIZE;
-       }
-    }
     SERVER_START_REQ( set_window_info )
     {
         req->handle    = hwnd;