1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Handle WM_IME_COMPOSITION for MBCS support

Add handling for WM_IME_COMPOSITION to ensure correct WM_IME_CHAR values in MBCS apps.
This commit is contained in:
ulhc 2025-12-03 19:00:27 +08:00 committed by GitHub
parent 48e655706d
commit 80b6e513ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -879,15 +879,19 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandlerEx(HWND hwnd, UINT msg, WPA
case WM_INPUTLANGCHANGE:
ImGui_ImplWin32_UpdateKeyboardCodePage(io);
return 0;
case WM_IME_COMPOSITION:
{
// Handling WM_IME_COMPOSITION ensure that WM_IME_CHAR value is correct even for MBCS apps.
// (see #9099, #3653 and https://stackoverflow.com/questions/77450354 topics)
LRESULT result = ::DefWindowProc(hwnd, msg, wParam, lParam);
return (lParam & GCS_RESULTSTR) ? 1 : result;
}
case WM_IME_CHAR :
if (::IsWindowUnicode(hwnd) == FALSE)
{
unsigned short ch = (unsigned short)wParam;
if (::IsDBCSLeadByte(HIBYTE(wParam)))
{
ch = MAKEWORD(HIBYTE(wParam), LOBYTE(wParam));
}
wchar_t wch = 0;
::MultiByteToWideChar(bd->KeyboardCodePage, MB_PRECOMPOSED, (char*)&ch, sizeof(ch), &wch, 1);
io.AddInputCharacterUTF16(wch);