Commit 3606dc55 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Added mapping to/from unicode for WM_CHAR, WM_DEADCHAR, WM_SYSCHAR,

WM_SYSDEADCHAR messages.
parent 7f126019
...@@ -48,9 +48,9 @@ extern BOOL WINPROC_SetProc( HWINDOWPROC *pFirst, WNDPROC16 func, ...@@ -48,9 +48,9 @@ extern BOOL WINPROC_SetProc( HWINDOWPROC *pFirst, WNDPROC16 func,
extern void WINPROC_FreeProc( HWINDOWPROC proc, WINDOWPROCUSER user ); extern void WINPROC_FreeProc( HWINDOWPROC proc, WINDOWPROCUSER user );
extern WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc ); extern WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc );
extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam,
LPARAM *plparam ); LPARAM *plparam );
extern INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, extern INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam,
LPARAM *plparam ); LPARAM *plparam );
extern INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, extern INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16,
UINT *pmsg32, WPARAM *pwparam32, UINT *pmsg32, WPARAM *pwparam32,
......
...@@ -1083,7 +1083,7 @@ static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType ) ...@@ -1083,7 +1083,7 @@ static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType )
} }
case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ): case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ):
switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) ) switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, &msg->wParam, &msg->lParam ) )
{ {
case 0: case 0:
return TRUE; return TRUE;
...@@ -1095,7 +1095,7 @@ static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType ) ...@@ -1095,7 +1095,7 @@ static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType )
} }
case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ): case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ):
switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) ) switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, &msg->wParam, &msg->lParam ) )
{ {
case 0: case 0:
return TRUE; return TRUE;
...@@ -1185,7 +1185,8 @@ static BOOL MSG_PeekMessage( int type, LPMSG msg, HWND hwnd, ...@@ -1185,7 +1185,8 @@ static BOOL MSG_PeekMessage( int type, LPMSG msg, HWND hwnd,
MSG tmpMsg = qmsg->msg; MSG tmpMsg = qmsg->msg;
if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) ) if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) )
{ {
ERR( "Message of wrong type contains pointer parameters. Skipped!\n "); ERR( "Message %s of wrong type contains pointer parameters. Skipped!\n",
SPY_GetMsgName(tmpMsg.message));
QUEUE_RemoveMsg( msgQueue, qmsg ); QUEUE_RemoveMsg( msgQueue, qmsg );
goto retry; goto retry;
} }
......
...@@ -546,21 +546,21 @@ static BOOL WINPROC_TestLBForStr ( HWND hwnd ) ...@@ -546,21 +546,21 @@ static BOOL WINPROC_TestLBForStr ( HWND hwnd )
* 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.
* *
* FIXME: * FIXME:
* WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR * WM_CHARTOITEM, WM_MENUCHAR
* *
* FIXME: * FIXME:
* WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style: * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
* the first four bytes are the handle of the icon * the first four bytes are the handle of the icon
* when the WM_SETTEXT message has been used to set the icon * when the WM_SETTEXT message has been used to set the icon
*/ */
INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plparam )
{ {
switch(msg) switch(msg)
{ {
case WM_GETTEXT: case WM_GETTEXT:
{ {
LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
wParam * sizeof(WCHAR) + sizeof(LPARAM) ); *pwparam * sizeof(WCHAR) + sizeof(LPARAM) );
if (!ptr) return -1; if (!ptr) return -1;
*ptr++ = *plparam; /* Store previous lParam */ *ptr++ = *plparam; /* Store previous lParam */
*plparam = (LPARAM)ptr; *plparam = (LPARAM)ptr;
...@@ -663,6 +663,18 @@ INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ...@@ -663,6 +663,18 @@ INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam
} }
return 1; return 1;
case WM_CHAR:
case WM_DEADCHAR:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
{
char ch = *pwparam;
WCHAR wch;
MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
*pwparam = wch;
}
return 0;
case WM_ASKCBFORMATNAME: case WM_ASKCBFORMATNAME:
case WM_DEVMODECHANGE: case WM_DEVMODECHANGE:
case WM_PAINTCLIPBOARD: case WM_PAINTCLIPBOARD:
...@@ -783,13 +795,14 @@ void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ...@@ -783,13 +795,14 @@ void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
* Map a message from Unicode to Ansi. * Map a message from Unicode to 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_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plparam )
{ switch(msg) {
switch(msg)
{ {
case WM_GETTEXT: case WM_GETTEXT:
{ {
LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
wParam + sizeof(LPARAM) ); *pwparam + sizeof(LPARAM) );
if (!ptr) return -1; if (!ptr) return -1;
*ptr++ = *plparam; /* Store previous lParam */ *ptr++ = *plparam; /* Store previous lParam */
*plparam = (LPARAM)ptr; *plparam = (LPARAM)ptr;
...@@ -887,6 +900,18 @@ INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ...@@ -887,6 +900,18 @@ INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam
} }
return 1; return 1;
case WM_CHAR:
case WM_DEADCHAR:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
{
WCHAR wch = *pwparam;
char ch;
WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL );
*pwparam = ch;
}
return 0;
case WM_ASKCBFORMATNAME: case WM_ASKCBFORMATNAME:
case WM_DEVMODECHANGE: case WM_DEVMODECHANGE:
case WM_PAINTCLIPBOARD: case WM_PAINTCLIPBOARD:
...@@ -1380,7 +1405,7 @@ INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *p ...@@ -1380,7 +1405,7 @@ INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *p
case WM_GETTEXT: case WM_GETTEXT:
case WM_SETTEXT: case WM_SETTEXT:
*plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam); *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, *pwparam32, plparam ); return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, pwparam32, plparam );
case WM_NCCREATE: case WM_NCCREATE:
case WM_CREATE: case WM_CREATE:
{ {
...@@ -1444,6 +1469,19 @@ INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *p ...@@ -1444,6 +1469,19 @@ INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *p
return 1; return 1;
} }
else return 0; else return 0;
case WM_CHAR:
case WM_DEADCHAR:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
{
char ch = wParam16;
WCHAR wch;
MultiByteToWideChar( CP_ACP, 0, &ch, 1, &wch, 1);
*pwparam32 = wch;
}
return 0;
default: /* No Unicode translation needed */ default: /* No Unicode translation needed */
return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32, return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32,
pwparam32, plparam ); pwparam32, plparam );
...@@ -2219,6 +2257,19 @@ INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32, WPARAM wParam32, ...@@ -2219,6 +2257,19 @@ INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32, WPARAM wParam32,
*plparam = (LPARAM)SEGPTR_GET(str); *plparam = (LPARAM)SEGPTR_GET(str);
} }
return 1; return 1;
case WM_CHAR:
case WM_DEADCHAR:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
{
WCHAR wch = wParam32;
char ch;
WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL);
*pwparam16 = ch;
}
return 0;
default: /* No Unicode translation needed (?) */ default: /* No Unicode translation needed (?) */
return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16, return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16,
pwparam16, plparam ); pwparam16, plparam );
...@@ -2271,7 +2322,7 @@ static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd, ...@@ -2271,7 +2322,7 @@ static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
{ {
LRESULT result; LRESULT result;
if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0; if (WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam ) == -1) return 0;
result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam ); WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
return result; return result;
...@@ -2289,7 +2340,7 @@ static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd, ...@@ -2289,7 +2340,7 @@ static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
{ {
LRESULT result; LRESULT result;
if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0; if (WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam ) == -1) return 0;
result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam ); WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
return result; return result;
......
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