[PATCH 5/14] user32: Move the call to the WH_CBT hook from graphics drivers' CreateWindow to user32's CreateWindow

Pierre d'Herbemont pdherbemont at free.fr
Sun Jan 21 17:35:37 CST 2007


---
   dlls/user32/win.c         |   25 +++++++++++++++++++++++++
   dlls/winex11.drv/window.c |   21 +--------------------
   2 files changed, 26 insertions(+), 20 deletions(-)

-------------- next part --------------
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 6be3924..d417c88 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -865,6 +865,9 @@ static HWND WIN_CreateWindowEx( CREATEST
     HWND hwnd, parent, owner, top_child = 0;
     BOOL unicode = (flags & WIN_ISUNICODE) != 0;
     MDICREATESTRUCTA mdi_cs;
+    CBT_CREATEWNDA cbtc;
+    CREATESTRUCTA cbcs;
+    RECT rect;
 
     TRACE("%s %s ex=%08x style=%08x %d,%d %dx%d parent=%p menu=%p inst=%p params=%p\n",
           unicode ? debugstr_w((LPCWSTR)cs->lpszName) : debugstr_a(cs->lpszName),
@@ -1098,6 +1101,28 @@ static HWND WIN_CreateWindowEx( CREATEST
         cs->cy = 0;
     }
 
+    /* initialize the dimensions before sending WM_GETMINMAXINFO */
+    SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
+    USER_Driver->pSetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER, NULL );
+
+    /* Call the WH_CBT hook */
+
+    /* the window style passed to the hook must be the real window style,
+     * rather than just the window style that the caller to CreateWindowEx
+     * passed in, so we have to copy the original CREATESTRUCT and get the
+     * the real style. */
+    cbcs = *cs;
+    cbcs.style = GetWindowLongW(hwnd, GWL_STYLE);
+
+    cbtc.lpcs = &cbcs;
+    cbtc.hwndInsertAfter = HWND_TOP;
+    if (HOOK_CallHooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, unicode ))
+    {
+        TRACE("CBT-hook returned !0\n");
+        WIN_DestroyWindow( hwnd );
+        return 0;
+    }
+
     if (!USER_Driver->pCreateWindow( hwnd, cs, unicode))
     {
         WIN_DestroyWindow( hwnd );
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 949a401..76d7ea2 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1010,13 +1010,11 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CRE
     HWND insert_after;
     RECT rect;
     DWORD style;
-    CBT_CREATEWNDA cbtc;
-    CREATESTRUCTA cbcs;
     BOOL ret = FALSE;
 
     if (!(data = alloc_win_data( display, hwnd ))) return FALSE;
 
-    /* initialize the dimensions before sending WM_GETMINMAXINFO */
+    /* init the win_data dimension */
     SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
     X11DRV_SetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER, NULL );
 
@@ -1033,23 +1031,6 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CRE
     /* get class or window DC if needed */
     alloc_window_dce( data );
 
-    /* Call the WH_CBT hook */
-
-    /* the window style passed to the hook must be the real window style,
-     * rather than just the window style that the caller to CreateWindowEx
-     * passed in, so we have to copy the original CREATESTRUCT and get the
-     * the real style. */
-    cbcs = *cs;
-    cbcs.style = GetWindowLongW(hwnd, GWL_STYLE);
-
-    cbtc.lpcs = &cbcs;
-    cbtc.hwndInsertAfter = HWND_TOP;
-    if (HOOK_CallHooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, unicode ))
-    {
-        TRACE("CBT-hook returned !0\n");
-        goto failed;
-    }
-
     /* Send the WM_GETMINMAXINFO message and fix the size if needed */
     if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
     {


More information about the wine-patches mailing list