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

This commit is contained in:
Alexandre Julliard 2009-12-21 11:21:48 +01:00
parent 6fd93a6c7e
commit ce50559013
5 changed files with 81 additions and 70 deletions

View File

@ -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 );

View File

@ -1999,73 +1999,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
*/
@ -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
};

View File

@ -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 );
}

View File

@ -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 */
};

View File

@ -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"
@ -1788,6 +1789,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)
*/