From db9b54925d69198db62b3b6728395ed4965ab7e6 Mon Sep 17 00:00:00 2001 From: "Guy L. Albertelli" Date: Fri, 7 Sep 2001 18:38:57 +0000 Subject: [PATCH] Enhance SPY_GetMsgName to translate common control messages. --- controls/combo.c | 2 +- controls/listbox.c | 4 ++-- dlls/user/message.c | 10 +++++----- include/spy.h | 2 +- windows/message.c | 6 +++--- windows/spy.c | 37 +++++++++++++++++++++++-------------- windows/winproc.c | 12 ++++++------ 7 files changed, 41 insertions(+), 32 deletions(-) diff --git a/controls/combo.c b/controls/combo.c index 95ccd63e6a1..9b74ac145d5 100644 --- a/controls/combo.c +++ b/controls/combo.c @@ -1859,7 +1859,7 @@ static LRESULT ComboWndProc_common( HWND hwnd, UINT message, LPHEADCOMBO lphc = (LPHEADCOMBO)GetWindowLongA( hwnd, 0 ); TRACE("[%04x]: msg %s wp %08x lp %08lx\n", - hwnd, SPY_GetMsgName(message), wParam, lParam ); + hwnd, SPY_GetMsgName(message, hwnd), wParam, lParam ); if( lphc || message == WM_NCCREATE ) switch(message) diff --git a/controls/listbox.c b/controls/listbox.c index ff55edd0394..042f131168a 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -2478,7 +2478,7 @@ static LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, } TRACE("[%04x]: msg %s wp %08x lp %08lx\n", - hwnd, SPY_GetMsgName(msg), wParam, lParam ); + hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam ); switch(msg) { case LB_RESETCONTENT16: @@ -3041,7 +3041,7 @@ static LRESULT WINAPI ComboLBWndProc_common( HWND hwnd, UINT msg, LB_DESCR *descr = (LB_DESCR *)GetWindowLongA( hwnd, 0 ); TRACE_(combo)("[%04x]: msg %s wp %08x lp %08lx\n", - hwnd, SPY_GetMsgName(msg), wParam, lParam ); + hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam ); if( descr || msg == WM_CREATE ) { diff --git a/dlls/user/message.c b/dlls/user/message.c index f55967dac0b..fe8e1b09dd4 100644 --- a/dlls/user/message.c +++ b/dlls/user/message.c @@ -567,7 +567,7 @@ static size_t pack_message( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara case WM_DRAGSELECT: case WM_DRAGMOVE: case WM_DEVICECHANGE: - FIXME( "msg %x (%s) not supported yet\n", message, SPY_GetMsgName(message) ); + FIXME( "msg %x (%s) not supported yet\n", message, SPY_GetMsgName(message, hwnd) ); data->count = -1; return 0; } @@ -813,7 +813,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa case WM_DRAGSELECT: case WM_DRAGMOVE: case WM_DEVICECHANGE: - FIXME( "msg %x (%s) not supported yet\n", message, SPY_GetMsgName(message) ); + FIXME( "msg %x (%s) not supported yet\n", message, SPY_GetMsgName(message, hwnd) ); return FALSE; default: @@ -1203,7 +1203,7 @@ BOOL MSG_peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags ) &info.msg.lParam, &buffer, size )) { ERR( "invalid packed message %x (%s) hwnd %x wp %x lp %lx size %d\n", - info.msg.message, SPY_GetMsgName(info.msg.message), info.msg.hwnd, + info.msg.message, SPY_GetMsgName(info.msg.message, info.msg.hwnd), info.msg.hwnd, info.msg.wParam, info.msg.lParam, size ); /* ignore it */ reply_message( &info, 0, TRUE ); @@ -1424,7 +1424,7 @@ static LRESULT retrieve_reply( const struct send_message_info *info, } TRACE( "hwnd %x msg %x (%s) wp %x lp %lx got reply %lx (err=%ld)\n", - info->hwnd, info->msg, SPY_GetMsgName(info->msg), info->wparam, + info->hwnd, info->msg, SPY_GetMsgName(info->msg, info->hwnd), info->wparam, info->lparam, *result, status ); if (!status) return 1; @@ -1445,7 +1445,7 @@ static LRESULT send_inter_thread_message( DWORD dest_tid, const struct send_mess size_t reply_size = 0; TRACE( "hwnd %x msg %x (%s) wp %x lp %lx\n", - info->hwnd, info->msg, SPY_GetMsgName(info->msg), info->wparam, info->lparam ); + info->hwnd, info->msg, SPY_GetMsgName(info->msg, info->hwnd), info->wparam, info->lparam ); if (!put_message_in_queue( dest_tid, info, &reply_size )) return 0; diff --git a/include/spy.h b/include/spy.h index 03140a4a666..93f3c614f7e 100644 --- a/include/spy.h +++ b/include/spy.h @@ -22,7 +22,7 @@ #define SPY_RESULT_DEFWND 0x0005 -extern const char *SPY_GetMsgName( UINT msg ); +extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ); extern const char *SPY_GetVKeyName(WPARAM wParam); extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); diff --git a/windows/message.c b/windows/message.c index 2134854f0f3..1a68a2267bf 100644 --- a/windows/message.c +++ b/windows/message.c @@ -830,7 +830,7 @@ BOOL WINAPI TranslateMessage( const MSG *msg ) if (msg->message >= WM_KEYFIRST && msg->message <= WM_KEYLAST) TRACE_(key)("(%s, %04X, %08lX)\n", - SPY_GetMsgName(msg->message), msg->wParam, msg->lParam ); + SPY_GetMsgName(msg->message, msg->hwnd), msg->wParam, msg->lParam ); if ((msg->message != WM_KEYDOWN) && (msg->message != WM_SYSKEYDOWN)) return FALSE; @@ -864,14 +864,14 @@ BOOL WINAPI TranslateMessage( const MSG *msg ) } dead_char = 0; } - TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message)); + TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message, msg->hwnd)); PostMessageW( msg->hwnd, message, wp[0], msg->lParam ); return TRUE; case -1: message = (msg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR; dead_char = wp[0]; - TRACE_(key)("-1 -> PostMessage(%s)\n", SPY_GetMsgName(message)); + TRACE_(key)("-1 -> PostMessage(%s)\n", SPY_GetMsgName(message, msg->hwnd)); PostMessageW( msg->hwnd, message, wp[0], msg->lParam ); return TRUE; } diff --git a/windows/spy.c b/windows/spy.c index c3c4bbcbb89..1a3960758a2 100644 --- a/windows/spy.c +++ b/windows/spy.c @@ -1579,11 +1579,14 @@ typedef struct CHAR wnd_name[16]; /* window name for message */ } SPY_INSTANCE; +/* This is defined so that the external entry point can return the addr */ +static SPY_INSTANCE ext_sp_e; + /*********************************************************************** * SPY_GetMsgInternal */ -static const char *SPY_GetMsgInternal( UINT msg, BOOL support_common_clts ) +static const char *SPY_GetMsgInternal( UINT msg ) { static char msg_buffer[20]; @@ -1673,7 +1676,7 @@ static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e ) const USER_MSG *p; sp_e->msg_name[sizeof(sp_e->msg_name)-1] = 0; - strncpy (sp_e->msg_name, SPY_GetMsgInternal( sp_e->msgnum, TRUE ), + strncpy (sp_e->msg_name, SPY_GetMsgInternal( sp_e->msgnum ), sizeof(sp_e->msg_name)-1); sp_e->data_len = 0; @@ -1698,18 +1701,6 @@ static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e ) } } -/*********************************************************************** - * SPY_GetMsgName - * - * **** External function **** - * - * Get message name - */ -const char *SPY_GetMsgName( UINT msg ) -{ - return SPY_GetMsgInternal( msg, FALSE ); -} - /*********************************************************************** * SPY_GetWndName * @@ -1765,6 +1756,24 @@ void SPY_GetWndName( SPY_INSTANCE *sp_e ) return; } +/*********************************************************************** + * SPY_GetMsgName + * + * **** External function **** + * + * Get message name + */ +const char *SPY_GetMsgName( UINT msg, HWND hWnd ) +{ + ext_sp_e.msgnum = msg; + ext_sp_e.msg_hwnd = hWnd; + ext_sp_e.lParam = 0; + ext_sp_e.wParam = 0; + SPY_GetWndName(&ext_sp_e); + SPY_GetMsgStuff(&ext_sp_e); + return ext_sp_e.msg_name; +} + /*********************************************************************** * SPY_GetVKeyName */ diff --git a/windows/winproc.c b/windows/winproc.c index 21dcca4f297..02191355f9d 100644 --- a/windows/winproc.c +++ b/windows/winproc.c @@ -165,7 +165,7 @@ static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg, hwnd = WIN_GetFullHandle( hwnd ); if (TRACE_ON(relay)) DPRINTF( "%08lx:Call window proc %p (hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n", - GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg), wParam, lParam ); + GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam ); /* To avoid any deadlocks, all the locks on the windows structures must be suspended before the control is passed to the application */ iWndsLocks = WIN_SuspendWndsLock(); @@ -174,7 +174,7 @@ static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg, if (TRACE_ON(relay)) DPRINTF( "%08lx:Ret window proc %p (hwnd=%08x,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n", - GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg), wParam, lParam, retvalue ); + GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam, retvalue ); return retvalue; } @@ -680,7 +680,7 @@ INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plpara case WM_PAINTCLIPBOARD: case WM_SIZECLIPBOARD: - FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg ); + FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg, hwnd), msg ); return -1; default: /* No translation needed */ return 0; @@ -936,7 +936,7 @@ INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plpara case WM_PAINTCLIPBOARD: case WM_SIZECLIPBOARD: - FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg ); + FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg, hwnd),msg ); return -1; default: /* No translation needed */ return 0; @@ -2405,7 +2405,7 @@ static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd, if( (unmap = WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam )) == -1) { ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n", - SPY_GetMsgName(msg), wParam, lParam ); + SPY_GetMsgName(msg, hwnd), wParam, lParam ); return 0; } result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); @@ -2428,7 +2428,7 @@ static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd, if ((unmap = WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam )) == -1) { ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n", - SPY_GetMsgName(msg), wParam, lParam ); + SPY_GetMsgName(msg, hwnd), wParam, lParam ); return 0; } result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );