Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ImGui_ImplWin32_UpdateKeyboardCodePage': The way of obtaining Language Identifier is inconsistent with the explanation on the MSDN. #8304

Closed
mumupingw opened this issue Jan 10, 2025 · 2 comments

Comments

@mumupingw
Copy link

mumupingw commented Jan 10, 2025

Version/Branch of Dear ImGui:

Version 1.91.6, Branch: master

Back-ends:

imgui_impl_win32.cpp

Compiler, OS:

Windows11 + MSVC 2022

Full config/build information:

No response

Details:

My Question: The way of obtaining Language Identifier is inconsistent with the explanation on the MSDN. Does it have any potential problems?

ImGui_ImplWin32_UpdateKeyboardCodePage() in imgui_impl_win32.cpp:

    HKL keyboard_layout = ::GetKeyboardLayout(0);
    LCID keyboard_lcid = MAKELCID(HIWORD(keyboard_layout), SORT_DEFAULT);
    if (::GetLocaleInfoA(keyboard_lcid, (LOCALE_RETURN_NUMBER | LOCALE_IDEFAULTANSICODEPAGE), (LPSTR)&bd->KeyboardCodePage, sizeof(bd->KeyboardCodePage)) == 0)
        bd->KeyboardCodePage = CP_ACP; // Fallback to default ANSI code page when fails.

In msdn, however, it explains the return value of the GetKeyboardLayout function as this :

The return value is the input locale identifier for the thread. The low word contains a Language Identifier for the input language and the high word contains a device handle to the physical layout of the keyboard.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@PathogenDavid
Copy link
Contributor

This came up when this code was introduced: #6785 (comment)

The conclusion wasn't particularly satisfying but unless someone finds a better solution the function has been working properly as-is.

@ocornut
Copy link
Owner

ocornut commented Jan 10, 2025

Yes, see #6785. If you find something that's not working as expected happy to hear it.

@ocornut ocornut closed this as completed Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants