From 02e74fa8a65177a9200e5f8acee6b0e5e214a675 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 15 Dec 2009 13:16:50 +0100 Subject: [PATCH] user32: Implement UserRegisterWowHandlers function and add a handler for the button winproc. --- dlls/user32/button.c | 28 +++------------------------- dlls/user32/controls.h | 20 ++++++++++++++++++++ dlls/user32/msg16.c | 34 ++++++++++++++++++++++++++++++++++ dlls/user32/user16.c | 1 + dlls/user32/user32.spec | 2 +- dlls/user32/winproc.c | 18 ++++++++++++++++++ 6 files changed, 77 insertions(+), 26 deletions(-) diff --git a/dlls/user32/button.c b/dlls/user32/button.c index 9eb731c747e..42163eb3124 100644 --- a/dlls/user32/button.c +++ b/dlls/user32/button.c @@ -73,7 +73,6 @@ #include "windef.h" #include "winbase.h" #include "wingdi.h" -#include "wine/winuser16.h" #include "controls.h" #include "win.h" #include "user_private.h" @@ -230,8 +229,7 @@ static void setup_clipping( HWND hwnd, HDC hdc ) /*********************************************************************** * ButtonWndProc_common */ -static LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, - WPARAM wParam, LPARAM lParam, BOOL unicode ) +LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { RECT rect; POINT pt; @@ -547,33 +545,13 @@ static LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, return 0; } -/*********************************************************************** - * ButtonWndProc_wrapper16 - */ -static LRESULT ButtonWndProc_wrapper16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) -{ - static const UINT msg16_offset = BM_GETCHECK16 - BM_GETCHECK; - - switch (msg) - { - case BM_GETCHECK16: - case BM_SETCHECK16: - case BM_GETSTATE16: - case BM_SETSTATE16: - case BM_SETSTYLE16: - return ButtonWndProc_common( hwnd, msg - msg16_offset, wParam, lParam, FALSE ); - default: - return ButtonWndProc_common( hwnd, msg, wParam, lParam, unicode ); - } -} - /*********************************************************************** * ButtonWndProcW */ static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if (!IsWindow( hWnd )) return 0; - return ButtonWndProc_wrapper16( hWnd, uMsg, wParam, lParam, TRUE ); + return wow_handlers.button_proc( hWnd, uMsg, wParam, lParam, TRUE ); } @@ -583,7 +561,7 @@ static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARA static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if (!IsWindow( hWnd )) return 0; - return ButtonWndProc_wrapper16( hWnd, uMsg, wParam, lParam, FALSE ); + return wow_handlers.button_proc( hWnd, uMsg, wParam, lParam, FALSE ); } diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h index f51a3d9ded6..a407c93103b 100644 --- a/dlls/user32/controls.h +++ b/dlls/user32/controls.h @@ -57,6 +57,26 @@ extern const struct builtin_class_descr MESSAGE_builtin_class DECLSPEC_HIDDEN; extern const struct builtin_class_descr SCROLL_builtin_class DECLSPEC_HIDDEN; extern const struct builtin_class_descr STATIC_builtin_class DECLSPEC_HIDDEN; +/* Wow handlers */ + +struct wow_handlers16 +{ + LRESULT (*button_proc)(HWND,UINT,WPARAM,LPARAM,BOOL); +}; + +struct wow_handlers32 +{ + LRESULT (*button_proc)(HWND,UINT,WPARAM,LPARAM,BOOL); +}; + +extern struct wow_handlers16 wow_handlers DECLSPEC_HIDDEN; + +extern LRESULT ButtonWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDEN; + +extern void register_wow_handlers(void) DECLSPEC_HIDDEN; +extern void WINAPI UserRegisterWowHandlers( const struct wow_handlers16 *new, + struct wow_handlers32 *orig ); + extern WNDPROC EDIT_winproc_handle DECLSPEC_HIDDEN; /* Class functions */ diff --git a/dlls/user32/msg16.c b/dlls/user32/msg16.c index d5d4825daf9..b677e514010 100644 --- a/dlls/user32/msg16.c +++ b/dlls/user32/msg16.c @@ -23,12 +23,15 @@ #include "winerror.h" #include "win.h" #include "user_private.h" +#include "controls.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msg); DWORD USER16_AlertableWait = 0; +static struct wow_handlers32 wow_handlers32; + static LRESULT cwp_hook_callback( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result, void *arg ) { @@ -584,3 +587,34 @@ BOOL16 WINAPI TranslateMDISysAccel16( HWND16 hwndClient, LPMSG16 msg ) } return 0; } + + +/*********************************************************************** + * button_proc16 + */ +static LRESULT button_proc16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) +{ + static const UINT msg16_offset = BM_GETCHECK16 - BM_GETCHECK; + + switch (msg) + { + case BM_GETCHECK16: + case BM_SETCHECK16: + case BM_GETSTATE16: + case BM_SETSTATE16: + case BM_SETSTYLE16: + return wow_handlers32.button_proc( hwnd, msg - msg16_offset, wParam, lParam, FALSE ); + default: + return wow_handlers32.button_proc( hwnd, msg, wParam, lParam, unicode ); + } +} + +void register_wow_handlers(void) +{ + static const struct wow_handlers16 handlers16 = + { + button_proc16, + }; + + UserRegisterWowHandlers( &handlers16, &wow_handlers32 ); +} diff --git a/dlls/user32/user16.c b/dlls/user32/user16.c index 77b3759fc0b..34133e57296 100644 --- a/dlls/user32/user16.c +++ b/dlls/user32/user16.c @@ -1387,6 +1387,7 @@ BOOL WINAPI DllEntryPoint( DWORD reason, HINSTANCE16 inst, WORD ds, if (USER_HeapSel) return TRUE; /* already called */ USER_HeapSel = ds; + register_wow_handlers(); return TRUE; } diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 8cdc24cda43..4492e587a58 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -738,7 +738,7 @@ # @ stub UserLpkPSMTextOut # @ stub UserLpkTabbedTextOut @ stdcall UserRealizePalette(long) -@ stub UserRegisterWowHandlers +@ stdcall UserRegisterWowHandlers(ptr ptr) # @ stub UserSetDeviceHoldState @ stdcall UserSignalProc(long long long long) # @ stub VRipOutput diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index d08a59fb262..040fd725f39 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -2378,3 +2378,21 @@ INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, } return ret; } + + +/********************************************************************** + * UserRegisterWowHandlers (USER32.@) + * + * NOTE: no attempt has been made to be compatible here, + * the Windows function is most likely completely different. + */ +void WINAPI UserRegisterWowHandlers( const struct wow_handlers16 *new, struct wow_handlers32 *orig ) +{ + orig->button_proc = ButtonWndProc_common; + wow_handlers = *new; +} + +struct wow_handlers16 wow_handlers = +{ + ButtonWndProc_common, +};