Alexandre Julliard : user32: Send all CreateWindow calls through the WoW wrapper to allow mapping 16-bit instances .

Alexandre Julliard julliard at winehq.org
Mon Dec 21 09:39:46 CST 2009


Module: wine
Branch: master
Commit: ce50559013365073dd76ef1169fe42cd91bc2e29
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ce50559013365073dd76ef1169fe42cd91bc2e29

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Dec 21 11:21:48 2009 +0100

user32: Send all CreateWindow calls through the WoW wrapper to allow mapping 16-bit instances.

---

 dlls/user32/controls.h |    3 ++
 dlls/user32/msg16.c    |   81 ++++++++---------------------------------------
 dlls/user32/win.c      |    6 ++--
 dlls/user32/winproc.c  |    1 +
 dlls/user32/wnd16.c    |   60 +++++++++++++++++++++++++++++++++++
 5 files changed, 81 insertions(+), 70 deletions(-)

diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h
index 3bde456..956c32e 100644
--- a/dlls/user32/controls.h
+++ b/dlls/user32/controls.h
@@ -96,6 +96,7 @@ struct wow_handlers16
     LRESULT (*mdiclient_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
     LRESULT (*scrollbar_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
     LRESULT (*static_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
+    HWND    (*create_window)(CREATESTRUCTW*,LPCWSTR,HINSTANCE,UINT);
     LRESULT (*call_window_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
     LRESULT (*call_dialog_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
 };
@@ -123,6 +124,8 @@ extern LRESULT MDIClientWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HI
 extern LRESULT ScrollBarWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
 extern LRESULT StaticWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN;
 
+/* 16-bit support */
+extern HWND create_window16(CREATESTRUCTW*,LPCWSTR,HINSTANCE,UINT) DECLSPEC_HIDDEN;
 extern void register_wow_handlers(void) DECLSPEC_HIDDEN;
 extern void WINAPI UserRegisterWowHandlers( const struct wow_handlers16 *new,
                                             struct wow_handlers32 *orig );
diff --git a/dlls/user32/msg16.c b/dlls/user32/msg16.c
index c3365e8..db6de66 100644
--- a/dlls/user32/msg16.c
+++ b/dlls/user32/msg16.c
@@ -2000,73 +2000,6 @@ BOOL16 WINAPI TranslateMDISysAccel16( HWND16 hwndClient, LPMSG16 msg )
 
 
 /***********************************************************************
- *		CreateWindowEx (USER.452)
- */
-HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
-                                LPCSTR windowName, DWORD style, INT16 x,
-                                INT16 y, INT16 width, INT16 height,
-                                HWND16 parent, HMENU16 menu,
-                                HINSTANCE16 instance, LPVOID data )
-{
-    CREATESTRUCTA cs;
-    char buffer[256];
-    HWND hwnd;
-
-    /* Fix the coordinates */
-
-    cs.x  = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
-    cs.y  = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
-    cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
-    cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
-
-    /* Create the window */
-
-    cs.lpCreateParams = data;
-    cs.hInstance      = HINSTANCE_32(instance);
-    cs.hMenu          = HMENU_32(menu);
-    cs.hwndParent     = WIN_Handle32( parent );
-    cs.style          = style;
-    cs.lpszName       = windowName;
-    cs.lpszClass      = className;
-    cs.dwExStyle      = exStyle;
-
-    /* map to module handle */
-    if (instance) instance = GetExePtr( instance );
-
-    /* load the menu */
-    if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
-    {
-        WNDCLASSA class;
-
-        if (GetClassInfoA( HINSTANCE_32(instance), className, &class ))
-            cs.hMenu = HMENU_32( LoadMenu16( instance, class.lpszMenuName ));
-    }
-
-    if (!IS_INTRESOURCE(className))
-    {
-        WCHAR bufferW[256];
-
-        if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
-            return 0;
-        hwnd = wow_handlers32.create_window( (CREATESTRUCTW *)&cs, bufferW,
-                                             HINSTANCE_32(instance), 0 );
-    }
-    else
-    {
-        if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) ))
-        {
-            ERR( "bad atom %x\n", LOWORD(className));
-            return 0;
-        }
-        cs.lpszClass = buffer;
-        hwnd = wow_handlers32.create_window( (CREATESTRUCTW *)&cs, (LPCWSTR)className,
-                                             HINSTANCE_32(instance), 0 );
-    }
-    return HWND_16( hwnd );
-}
-
-
-/***********************************************************************
  *           button_proc16
  */
 static LRESULT button_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode )
@@ -2642,6 +2575,19 @@ static LRESULT static_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
 }
 
 
+/***********************************************************************
+ *           create_window16
+ */
+HWND create_window16( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE instance, UINT flags )
+{
+    /* map to module handle */
+    if (instance && !((ULONG_PTR)instance >> 16))
+        instance = HINSTANCE_32( GetExePtr( HINSTANCE_16(instance) ));
+
+    return wow_handlers32.create_window( cs, className, instance, flags );
+}
+
+
 void register_wow_handlers(void)
 {
     static const struct wow_handlers16 handlers16 =
@@ -2653,6 +2599,7 @@ void register_wow_handlers(void)
         mdiclient_proc16,
         scrollbar_proc16,
         static_proc16,
+        create_window16,
         call_window_proc_Ato16,
         call_dialog_proc_Ato16
     };
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 7834501..393c562 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -1465,11 +1465,11 @@ HWND WINAPI CreateWindowExA( DWORD exStyle, LPCSTR className,
         WCHAR bufferW[256];
         if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
             return 0;
-        return WIN_CreateWindowEx( (CREATESTRUCTW *)&cs, bufferW, instance, WIN_ISWIN32 );
+        return wow_handlers.create_window( (CREATESTRUCTW *)&cs, bufferW, instance, WIN_ISWIN32 );
     }
     /* Note: we rely on the fact that CREATESTRUCTA and */
     /* CREATESTRUCTW have the same layout. */
-    return WIN_CreateWindowEx( (CREATESTRUCTW *)&cs, (LPCWSTR)className, instance, WIN_ISWIN32 );
+    return wow_handlers.create_window( (CREATESTRUCTW *)&cs, (LPCWSTR)className, instance, WIN_ISWIN32 );
 }
 
 
@@ -1497,7 +1497,7 @@ HWND WINAPI CreateWindowExW( DWORD exStyle, LPCWSTR className,
     cs.lpszClass      = className;
     cs.dwExStyle      = exStyle;
 
-    return WIN_CreateWindowEx( &cs, className, instance, WIN_ISWIN32 | WIN_ISUNICODE );
+    return wow_handlers.create_window( &cs, className, instance, WIN_ISWIN32 | WIN_ISUNICODE );
 }
 
 
diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c
index 36f8279..48a9dbe 100644
--- a/dlls/user32/winproc.c
+++ b/dlls/user32/winproc.c
@@ -1152,6 +1152,7 @@ struct wow_handlers16 wow_handlers =
     MDIClientWndProc_common,
     ScrollBarWndProc_common,
     StaticWndProc_common,
+    WIN_CreateWindowEx,
     NULL,  /* call_window_proc */
     NULL   /* call_dialog_proc */
 };
diff --git a/dlls/user32/wnd16.c b/dlls/user32/wnd16.c
index 4873be7..ad99e6d 100644
--- a/dlls/user32/wnd16.c
+++ b/dlls/user32/wnd16.c
@@ -21,6 +21,7 @@
 #include "wine/winuser16.h"
 #include "wownt32.h"
 #include "win.h"
+#include "controls.h"
 #include "user_private.h"
 #include "wine/server.h"
 
@@ -1789,6 +1790,65 @@ BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
 
 
 /***********************************************************************
+ *		CreateWindowEx (USER.452)
+ */
+HWND16 WINAPI CreateWindowEx16( DWORD exStyle, LPCSTR className,
+                                LPCSTR windowName, DWORD style, INT16 x,
+                                INT16 y, INT16 width, INT16 height,
+                                HWND16 parent, HMENU16 menu,
+                                HINSTANCE16 instance, LPVOID data )
+{
+    CREATESTRUCTA cs;
+    char buffer[256];
+    HWND hwnd;
+
+    /* Fix the coordinates */
+
+    cs.x  = (x == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)x;
+    cs.y  = (y == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)y;
+    cs.cx = (width == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)width;
+    cs.cy = (height == CW_USEDEFAULT16) ? CW_USEDEFAULT : (INT)height;
+
+    /* Create the window */
+
+    cs.lpCreateParams = data;
+    cs.hInstance      = HINSTANCE_32(instance);
+    cs.hMenu          = HMENU_32(menu);
+    cs.hwndParent     = WIN_Handle32( parent );
+    cs.style          = style;
+    cs.lpszName       = windowName;
+    cs.lpszClass      = className;
+    cs.dwExStyle      = exStyle;
+
+    /* load the menu */
+    if (!menu && (style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
+    {
+        WNDCLASSA class;
+        HINSTANCE16 module = GetExePtr( instance );
+
+        if (GetClassInfoA( HINSTANCE_32(module), className, &class ))
+            cs.hMenu = HMENU_32( LoadMenu16( module, class.lpszMenuName ));
+    }
+
+    if (!IS_INTRESOURCE(className))
+    {
+        WCHAR bufferW[256];
+
+        if (!MultiByteToWideChar( CP_ACP, 0, className, -1, bufferW, sizeof(bufferW)/sizeof(WCHAR) ))
+            return 0;
+        hwnd = create_window16( (CREATESTRUCTW *)&cs, bufferW, HINSTANCE_32(instance), 0 );
+    }
+    else
+    {
+        if (!GlobalGetAtomNameA( LOWORD(className), buffer, sizeof(buffer) )) return 0;
+        cs.lpszClass = buffer;
+        hwnd = create_window16( (CREATESTRUCTW *)&cs, (LPCWSTR)className, HINSTANCE_32(instance), 0 );
+    }
+    return HWND_16( hwnd );
+}
+
+
+/***********************************************************************
  *		GetInternalWindowPos (USER.460)
  */
 UINT16 WINAPI GetInternalWindowPos16( HWND16 hwnd, LPRECT16 rectWnd, LPPOINT16 ptIcon )




More information about the wine-cvs mailing list