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:
parent
48e655706d
commit
80b6e513ba
1 changed files with 7 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue