Fix displaying Chinese characters as "??" in some applications with Chinese locale.
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/user32/tests/dialog.c | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index a24bfafd0b9..bac4524cecb 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -567,8 +567,38 @@ static LRESULT CALLBACK test_control_procA(HWND hwnd, UINT msg, WPARAM wparam, L return DefWindowProcA(hwnd, msg, wparam, lparam); }
+static int wm_char_count; + +static LRESULT CALLBACK test_IsDialogMessageA_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_CHAR: + if (GetSystemMetrics(SM_DBCSENABLED)) + { + todo_wine + ok(wparam == 0x5b57, "Got unexpected wparam %#Ix.\n", wparam); + } + else + ok(wparam == 0x3f, "Got unexpected wparam %#Ix.\n", wparam); + wm_char_count++; + return 0; + case WM_CLOSE: + DestroyWindow(hwnd); + return 0; + case WM_DESTROY: + PostQuitMessage(0); + return 0; + case WM_GETDLGCODE: + return DLGC_WANTCHARS; + default: + return DefWindowProcW(hwnd, msg, wparam, lparam); + } +} + static BOOL RegisterWindowClasses (void) { + WNDCLASSW cls_w; WNDCLASSA cls;
cls.style = 0; @@ -597,6 +627,11 @@ static BOOL RegisterWindowClasses (void) cls.lpszClassName = "WM_NEXTDLGCTLWndClass"; if (!RegisterClassA (&cls)) return FALSE;
+ memset (&cls_w, 0, sizeof(cls_w)); + cls_w.lpfnWndProc = test_IsDialogMessageA_proc; + cls_w.hInstance = g_hinst; + cls_w.lpszClassName = L"TestIsDialogMessageAClass"; + if (!RegisterClassW (&cls_w)) return FALSE; return TRUE; }
@@ -729,6 +764,8 @@ static LRESULT CALLBACK hook_proc2(INT code, WPARAM wParam, LPARAM lParam) static void test_IsDialogMessage(void) { HHOOK hook; + HWND child; + BOOL ret; MSG msg;
g_hwndMain = CreateWindowA("IsDialogMessageWindowClass", "IsDialogMessageWindowClass", @@ -816,6 +853,34 @@ static void test_IsDialogMessage(void) ok(IsDialogMessageA(g_hwndMain, &msg), "Did not handle the ENTER\n"); ok(g_button1Clicked, "Did not receive button 1 click notification\n");
+ /* Test IsDialogMessageA converting a WM_CHAR wparam in ASCII to Unicode */ + child = CreateWindowW(L"TestIsDialogMessageAClass", L"test", WS_CHILD | WS_VISIBLE, 0, 0, 10, + 10, g_hwndMain, 0, g_hinst, 0); + ok(!!child, "Failed to create a window, error %#lx.\n", GetLastError()); + + /* \u5b57 is a '字' in Chinese */ + PostMessageW(child, WM_CHAR, 0x5b57, 0x1); + PostMessageW(child, WM_CLOSE, 0, 0); + + while (GetMessageA(&msg, child, 0, 0) > 0) + { + if (msg.message == WM_CHAR) + { + if (GetSystemMetrics(SM_DBCSENABLED)) + ok(msg.wParam != 0x3f && msg.wParam != 0x5b57, "Got unexpected wparam %#Ix.\n", msg.wParam); + else + ok(msg.wParam == 0x3f, "Got unexpected wparam %#Ix.\n", msg.wParam); + ret = IsDialogMessageA(g_hwndMain, &msg); + ok(ret, "IsDialogMessageA failed.\n"); + } + else + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + } + todo_wine_if(GetSystemMetrics(SM_DBCSENABLED)) + ok(wm_char_count == 1, "Got unexpected WM_CHAR count %d.\n", wm_char_count); DestroyWindow(g_hwndMain); }
From: Zhiyi Zhang zzhang@codeweavers.com
Fix displaying Chinese characters as "??" in some applications with Chinese locale. --- dlls/user32/message.c | 6 +++++- dlls/user32/tests/dialog.c | 4 ---- include/ntuser.h | 1 + 3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c index acab4117cf2..4016c95539a 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -814,8 +814,12 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetMessageA( MSG *msg, HWND hwnd, UINT first, UINT */ BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG pmsg ) { + enum wm_char_mapping mapping; MSG msg = *pmsg; - map_wparam_AtoW( msg.message, &msg.wParam, WMCHAR_MAP_NOMAPPING ); + + mapping = GetSystemMetrics( SM_DBCSENABLED ) ? WMCHAR_MAP_ISDIALOGMESSAGE : WMCHAR_MAP_NOMAPPING; + if (!map_wparam_AtoW( msg.message, &msg.wParam, mapping )) + return TRUE; return IsDialogMessageW( hwndDlg, &msg ); }
diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c index bac4524cecb..18a9685b230 100644 --- a/dlls/user32/tests/dialog.c +++ b/dlls/user32/tests/dialog.c @@ -575,10 +575,7 @@ static LRESULT CALLBACK test_IsDialogMessageA_proc(HWND hwnd, UINT msg, WPARAM w { case WM_CHAR: if (GetSystemMetrics(SM_DBCSENABLED)) - { - todo_wine ok(wparam == 0x5b57, "Got unexpected wparam %#Ix.\n", wparam); - } else ok(wparam == 0x3f, "Got unexpected wparam %#Ix.\n", wparam); wm_char_count++; @@ -879,7 +876,6 @@ static void test_IsDialogMessage(void) DispatchMessageA(&msg); } } - todo_wine_if(GetSystemMetrics(SM_DBCSENABLED)) ok(wm_char_count == 1, "Got unexpected WM_CHAR count %d.\n", wm_char_count); DestroyWindow(g_hwndMain); } diff --git a/include/ntuser.h b/include/ntuser.h index b873512dbd1..a8e8f4d6da0 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -135,6 +135,7 @@ enum wm_char_mapping WMCHAR_MAP_RECVMESSAGE, WMCHAR_MAP_DISPATCHMESSAGE, WMCHAR_MAP_CALLWINDOWPROC, + WMCHAR_MAP_ISDIALOGMESSAGE, WMCHAR_MAP_COUNT, WMCHAR_MAP_NOMAPPING = WMCHAR_MAP_COUNT };
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=137374
Your paranoid android.
=== debian11 (32 bit hi:IN report) ===
user32: dialog.c:578: Test failed: Got unexpected wparam 0xfffd.