Commit 22a9d18b authored by Alexandre Julliard's avatar Alexandre Julliard

user: Use winproc callbacks for the remaining 16-bit messaging functions.

parent b8da6f27
...@@ -50,6 +50,34 @@ static LRESULT send_message_callback( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, ...@@ -50,6 +50,34 @@ static LRESULT send_message_callback( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
return *result; return *result;
} }
static LRESULT post_message_callback( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
LRESULT *result, void *arg )
{
*result = 0;
return PostMessageA( hwnd, msg, wp, lp );
}
static LRESULT post_thread_message_callback( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
LRESULT *result, void *arg )
{
DWORD_PTR tid = (DWORD_PTR)arg;
*result = 0;
return PostThreadMessageA( tid, msg, wp, lp );
}
static LRESULT get_message_callback( HWND16 hwnd, UINT16 msg, WPARAM16 wp, LPARAM lp,
LRESULT *result, void *arg )
{
MSG16 *msg16 = arg;
msg16->hwnd = hwnd;
msg16->message = msg;
msg16->wParam = wp;
msg16->lParam = lp;
*result = 0;
return 0;
}
/*********************************************************************** /***********************************************************************
* SendMessage (USER.111) * SendMessage (USER.111)
...@@ -85,22 +113,10 @@ LRESULT WINAPI SendMessage16( HWND16 hwnd16, UINT16 msg, WPARAM16 wparam, LPARAM ...@@ -85,22 +113,10 @@ LRESULT WINAPI SendMessage16( HWND16 hwnd16, UINT16 msg, WPARAM16 wparam, LPARAM
/*********************************************************************** /***********************************************************************
* PostMessage (USER.110) * PostMessage (USER.110)
*/ */
BOOL16 WINAPI PostMessage16( HWND16 hwnd16, UINT16 msg, WPARAM16 wparam, LPARAM lparam ) BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM lparam )
{ {
WPARAM wparam32; LRESULT unused;
UINT msg32; return WINPROC_CallProc16To32A( post_message_callback, hwnd, msg, wparam, lparam, &unused, NULL );
HWND hwnd = WIN_Handle32( hwnd16 );
switch (WINPROC_MapMsg16To32A( hwnd, msg, wparam, &msg32, &wparam32, &lparam ))
{
case 0:
return PostMessageA( hwnd, msg32, wparam32, lparam );
case 1:
ERR( "16-bit message 0x%04x contains pointer, cannot post\n", msg );
return FALSE;
default:
return FALSE;
}
} }
...@@ -109,21 +125,12 @@ BOOL16 WINAPI PostMessage16( HWND16 hwnd16, UINT16 msg, WPARAM16 wparam, LPARAM ...@@ -109,21 +125,12 @@ BOOL16 WINAPI PostMessage16( HWND16 hwnd16, UINT16 msg, WPARAM16 wparam, LPARAM
*/ */
BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 msg, WPARAM16 wparam, LPARAM lparam ) BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 msg, WPARAM16 wparam, LPARAM lparam )
{ {
WPARAM wparam32; LRESULT unused;
UINT msg32; DWORD_PTR tid = HTASK_32( hTask );
DWORD tid = HTASK_32( hTask );
if (!tid) return FALSE;
switch (WINPROC_MapMsg16To32A( 0, msg, wparam, &msg32, &wparam32, &lparam )) if (!tid) return FALSE;
{ return WINPROC_CallProc16To32A( post_thread_message_callback, 0, msg, wparam, lparam,
case 0: &unused, (void *)tid );
return PostThreadMessageA( tid, msg32, wparam32, lparam );
case 1:
ERR( "16-bit message %x contains pointer, cannot post\n", msg );
return FALSE;
default:
return FALSE;
}
} }
...@@ -153,22 +160,20 @@ BOOL16 WINAPI PeekMessage32_16( MSG32_16 *msg16, HWND16 hwnd16, ...@@ -153,22 +160,20 @@ BOOL16 WINAPI PeekMessage32_16( MSG32_16 *msg16, HWND16 hwnd16,
BOOL16 wHaveParamHigh ) BOOL16 wHaveParamHigh )
{ {
MSG msg; MSG msg;
LRESULT unused;
HWND hwnd = WIN_Handle32( hwnd16 ); HWND hwnd = WIN_Handle32( hwnd16 );
if(USER16_AlertableWait) if(USER16_AlertableWait)
MsgWaitForMultipleObjectsEx( 0, NULL, 1, 0, MWMO_ALERTABLE ); MsgWaitForMultipleObjectsEx( 0, NULL, 1, 0, MWMO_ALERTABLE );
if (!PeekMessageA( &msg, hwnd, first, last, flags )) return FALSE; if (!PeekMessageA( &msg, hwnd, first, last, flags )) return FALSE;
msg16->msg.hwnd = HWND_16( msg.hwnd );
msg16->msg.lParam = msg.lParam;
msg16->msg.time = msg.time; msg16->msg.time = msg.time;
msg16->msg.pt.x = (INT16)msg.pt.x; msg16->msg.pt.x = (INT16)msg.pt.x;
msg16->msg.pt.y = (INT16)msg.pt.y; msg16->msg.pt.y = (INT16)msg.pt.y;
if (wHaveParamHigh) msg16->wParamHigh = HIWORD(msg.wParam); if (wHaveParamHigh) msg16->wParamHigh = HIWORD(msg.wParam);
WINPROC_CallProc32ATo16( get_message_callback, msg.hwnd, msg.message, msg.wParam, msg.lParam,
return (WINPROC_MapMsg32ATo16( msg.hwnd, msg.message, msg.wParam, &unused, &msg16->msg );
&msg16->msg.message, &msg16->msg.wParam, return TRUE;
&msg16->msg.lParam ) != -1);
} }
...@@ -282,23 +287,18 @@ BOOL16 WINAPI GetMessage32_16( MSG32_16 *msg16, HWND16 hwnd16, UINT16 first, ...@@ -282,23 +287,18 @@ BOOL16 WINAPI GetMessage32_16( MSG32_16 *msg16, HWND16 hwnd16, UINT16 first,
UINT16 last, BOOL16 wHaveParamHigh ) UINT16 last, BOOL16 wHaveParamHigh )
{ {
MSG msg; MSG msg;
LRESULT unused;
HWND hwnd = WIN_Handle32( hwnd16 ); HWND hwnd = WIN_Handle32( hwnd16 );
do
{
if(USER16_AlertableWait) if(USER16_AlertableWait)
MsgWaitForMultipleObjectsEx( 0, NULL, INFINITE, 0, MWMO_ALERTABLE ); MsgWaitForMultipleObjectsEx( 0, NULL, INFINITE, 0, MWMO_ALERTABLE );
GetMessageA( &msg, hwnd, first, last ); GetMessageA( &msg, hwnd, first, last );
msg16->msg.hwnd = HWND_16( msg.hwnd );
msg16->msg.lParam = msg.lParam;
msg16->msg.time = msg.time; msg16->msg.time = msg.time;
msg16->msg.pt.x = (INT16)msg.pt.x; msg16->msg.pt.x = (INT16)msg.pt.x;
msg16->msg.pt.y = (INT16)msg.pt.y; msg16->msg.pt.y = (INT16)msg.pt.y;
if (wHaveParamHigh) msg16->wParamHigh = HIWORD(msg.wParam); if (wHaveParamHigh) msg16->wParamHigh = HIWORD(msg.wParam);
} WINPROC_CallProc32ATo16( get_message_callback, msg.hwnd, msg.message, msg.wParam, msg.lParam,
while (WINPROC_MapMsg32ATo16( msg.hwnd, msg.message, msg.wParam, &unused, &msg16->msg );
&msg16->msg.message, &msg16->msg.wParam,
&msg16->msg.lParam ) == -1);
TRACE( "message %04x, hwnd %p, filter(%04x - %04x)\n", TRACE( "message %04x, hwnd %p, filter(%04x - %04x)\n",
msg16->msg.message, hwnd, first, last ); msg16->msg.message, hwnd, first, last );
......
...@@ -728,7 +728,7 @@ static UINT convert_handle_16_to_32(HANDLE16 src, unsigned int flags) ...@@ -728,7 +728,7 @@ static UINT convert_handle_16_to_32(HANDLE16 src, unsigned int flags)
* Map a message from 16- to 32-bit Ansi. * Map a message from 16- to 32-bit Ansi.
* Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
*/ */
INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32, static INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
WPARAM *pwparam32, LPARAM *plparam ) WPARAM *pwparam32, LPARAM *plparam )
{ {
*pmsg32 = (UINT)msg16; *pmsg32 = (UINT)msg16;
...@@ -1372,9 +1372,8 @@ static HANDLE16 convert_handle_32_to_16(UINT src, unsigned int flags) ...@@ -1372,9 +1372,8 @@ static HANDLE16 convert_handle_32_to_16(UINT src, unsigned int flags)
* Map a message from 32-bit Ansi to 16-bit. * Map a message from 32-bit Ansi to 16-bit.
* Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
*/ */
INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32, static INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32,
UINT16 *pmsg16, WPARAM16 *pwparam16, UINT16 *pmsg16, WPARAM16 *pwparam16, LPARAM *plparam )
LPARAM *plparam )
{ {
*pmsg16 = (UINT16)msg32; *pmsg16 = (UINT16)msg32;
*pwparam16 = (WPARAM16)LOWORD(wParam32); *pwparam16 = (WPARAM16)LOWORD(wParam32);
......
...@@ -45,13 +45,6 @@ extern LRESULT WINPROC_CallProc16To32A( winproc_callback_t callback, HWND16 hwnd ...@@ -45,13 +45,6 @@ extern LRESULT WINPROC_CallProc16To32A( winproc_callback_t callback, HWND16 hwnd
extern LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT msg, extern LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg ); WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg );
extern INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16,
UINT *pmsg32, WPARAM *pwparam32,
LPARAM *plparam );
extern INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32,
WPARAM wParam32, UINT16 *pmsg16,
WPARAM16 *pwparam16, LPARAM *plparam );
extern INT_PTR WINPROC_CallDlgProc16( DLGPROC16 func, HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam ); extern INT_PTR WINPROC_CallDlgProc16( DLGPROC16 func, HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam );
extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment