Commit 334ede40 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Factor out the calling of a window's winproc into a separate function.

parent 01de889c
......@@ -1513,7 +1513,6 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
{
struct user_thread_info *thread_info = get_user_thread_info();
LRESULT result = 0;
WNDPROC winproc;
CWPSTRUCT cwp;
CWPRETSTRUCT cwpret;
......@@ -1535,16 +1534,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, same_thread, (LPARAM)&cwp, unicode );
/* now call the window procedure */
if (unicode)
{
if (!(winproc = (WNDPROC)GetWindowLongPtrW( hwnd, GWLP_WNDPROC ))) goto done;
result = CallWindowProcW( winproc, hwnd, msg, wparam, lparam );
}
else
{
if (!(winproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ))) goto done;
result = CallWindowProcA( winproc, hwnd, msg, wparam, lparam );
}
if (!WINPROC_call_window( hwnd, msg, wparam, lparam, &result, unicode )) goto done;
/* and finally the WH_CALLWNDPROCRET hook */
cwpret.lResult = result;
......@@ -2971,9 +2961,7 @@ BOOL WINAPI TranslateMessage( const MSG *msg )
*/
LRESULT WINAPI DispatchMessageA( const MSG* msg )
{
WND * wndPtr;
LRESULT retval;
WNDPROC winproc;
/* Process timer messages */
if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
......@@ -2981,31 +2969,19 @@ LRESULT WINAPI DispatchMessageA( const MSG* msg )
if (msg->lParam) return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
msg->message, msg->wParam, GetTickCount() );
}
if (!msg->hwnd) return 0;
if (!(wndPtr = WIN_GetPtr( msg->hwnd )))
{
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr->tid != GetCurrentThreadId())
SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
msg->wParam, msg->lParam );
if (!WINPROC_call_window( msg->hwnd, msg->message, msg->wParam, msg->lParam,
&retval, FALSE ))
{
SetLastError( ERROR_MESSAGE_SYNC_ONLY );
WIN_ReleasePtr( wndPtr );
return 0;
if (!IsWindow( msg->hwnd )) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
else SetLastError( ERROR_MESSAGE_SYNC_ONLY );
retval = 0;
}
winproc = wndPtr->winproc;
WIN_ReleasePtr( wndPtr );
SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
msg->wParam, msg->lParam );
retval = CallWindowProcA( winproc, msg->hwnd, msg->message,
msg->wParam, msg->lParam );
SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval,
msg->wParam, msg->lParam );
......@@ -3043,9 +3019,7 @@ LRESULT WINAPI DispatchMessageA( const MSG* msg )
*/
LRESULT WINAPI DispatchMessageW( const MSG* msg )
{
WND * wndPtr;
LRESULT retval;
WNDPROC winproc;
/* Process timer messages */
if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
......@@ -3053,31 +3027,19 @@ LRESULT WINAPI DispatchMessageW( const MSG* msg )
if (msg->lParam) return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
msg->message, msg->wParam, GetTickCount() );
}
if (!msg->hwnd) return 0;
if (!(wndPtr = WIN_GetPtr( msg->hwnd )))
{
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr->tid != GetCurrentThreadId())
SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
msg->wParam, msg->lParam );
if (!WINPROC_call_window( msg->hwnd, msg->message, msg->wParam, msg->lParam,
&retval, TRUE ))
{
SetLastError( ERROR_MESSAGE_SYNC_ONLY );
WIN_ReleasePtr( wndPtr );
return 0;
if (!IsWindow( msg->hwnd )) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
else SetLastError( ERROR_MESSAGE_SYNC_ONLY );
retval = 0;
}
winproc = wndPtr->winproc;
WIN_ReleasePtr( wndPtr );
SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
msg->wParam, msg->lParam );
retval = CallWindowProcW( winproc, msg->hwnd, msg->message,
msg->wParam, msg->lParam );
SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval,
msg->wParam, msg->lParam );
......
......@@ -246,6 +246,8 @@ extern LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd
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_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
LRESULT *result, BOOL unicode );
/* message spy definitions */
......
......@@ -2197,6 +2197,47 @@ LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT
/**********************************************************************
* WINPROC_call_window
*
* Call the window procedure of the specified window.
*/
BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
LRESULT *result, BOOL unicode )
{
WND *wndPtr;
WINDOWPROC *proc;
if (!(wndPtr = WIN_GetPtr( hwnd ))) return FALSE;
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
if (wndPtr->tid != GetCurrentThreadId())
{
WIN_ReleasePtr( wndPtr );
return FALSE;
}
proc = handle_to_proc( wndPtr->winproc );
WIN_ReleasePtr( wndPtr );
if (!proc) return TRUE;
if (unicode)
{
if (proc->procW)
call_window_proc( hwnd, msg, wParam, lParam, result, proc->procW );
else
WINPROC_CallProcWtoA( call_window_proc, hwnd, msg, wParam, lParam, result, proc->procA );
}
else
{
if (proc->procA)
call_window_proc( hwnd, msg, wParam, lParam, result, proc->procA );
else
WINPROC_CallProcAtoW( call_window_proc, hwnd, msg, wParam, lParam, result, proc->procW );
}
return TRUE;
}
/**********************************************************************
* CallWindowProc (USER.122)
*/
LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg,
......
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