Activate keyboard layout for Chinese and Japanese in Windows 10 - c++

I am developing an application which according to an input locale identifier of a language (ex: US keyboard -> "00000409" or German keyboard -> "00000407") https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-language-pack-default-values, activates a keyboard layout according to the language selected.
HKL desiredKeyboardLayout = LoadKeyboardLayout(idLanguage, 0);
ActivateKeyboardLayout(desiredKeyboardLayout, KLF_ACTIVATE);
Nevertheless, when I try to change the layout to Chinese or Japanese, the layout showed is US Keyboard...
Is there any way to activate layouts for these languages?
I will appreciate any kind of help.

Related

GetKeyboardLayout() doesn't change when switching between ENG US and ENG INT

This is for an app running on Windows 10. I have two keyboard layouts loaded, ENG US and ENG INT
I am using GetKeyboardLayout(0) however I get the same result regardless of which layout I'm using.
How can I detect which of the two keyboard layouts are in use?
This maybe my mistake, if I make the call like
GetKeyboardLayout(GetWindowThreadProcessId(::GetForegroundWindow(), 0))
Then I get the correct result each time. Now I'm confused because I was under the impression that the keyboard layout was global on Windows 10.
Languages, Locales, and Keyboard Layouts:
Applications typically use locales to set the language in which input
and output is processed. Setting the locale for the keyboard, for
example, affects the character values generated by the keyboard.
Setting the locale for the display or printer affects the glyphs
displayed or printed. Applications set the locale for a keyboard by
loading and using keyboard layouts. They set the locale for a display
or printer by selecting a font that supports the specified locale.
Applications are generally not expected to manipulate input languages
directly. Instead, the user sets up language and layout combinations,
then switches among them.
Calls the ActivateKeyboardLayout function to activate the user's default layout for that language.
Calls the GetKeyboardLayout function to get layout.
Both are thread-based or process-based.
I guess what you might want to get is the input locale identifier for the system default input language, which is global.
SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, &hkl, 0);

can't add Hebrew to keyboard layout

I'm running on
NAME="openSUSE Leap" VERSION="42.3"
I've added Hebrew as a secondary language but in the System Keyboard Layout there is no Hebrew layout.
Any suggestions?
The solution was to Configure Desktop -> Input Devices -> Keyboard -> Layouts , there you can add a new Layout.

Win API to change keyboard language programmatically in C++

I want to change the input language in Windows7 programmatically.
I have been used LoadKeyboardLayout and ActivateKeyboardLayout,
try to change my keyboard language, but it only work on Windows XP
Is there any other API to suport that?
Thanks

How to convert X11 KeyCode or KeySym to scan code

I need to get scan codes of keyboard buttons (or any other codes) in layout-independent way. More specific, let's say I have QEditText and catching keystrokes from it. Now I'm starting to press a single button, and when the layout is English it has keycode=X, then I'm switching layout to Russian (German, French, whatever) and keycode becomes Y - but the physical button is the same. So I need to know code of that physical button, how to do this?
I am not sure if you will be able to do this only from code itself by some qt/x11 methods, but there is a tool that helps in similar situations: xbindkeys. You can read more here:
https://unix.stackexchange.com/questions/91355/shortcut-keys-that-are-independent-to-keyboard-layout
If you can't use xbindkeys, you can still check its code and see how the author achieved this.

Could not display other unicode Eastern Asian Lanuage on Windows DialogBox

I use the DialogBox API to display a dialog at my application. In the WM_INITDIALOG message handling at the DLGPROC procedure call back, I could see the text string is correct Unicode at debugger and SetDlgItemText is used to set the text on Rich Edit control in the dialog. However when I tried to get the text from dialog by using GetDlgItemText API , it was all question marks for those characters.
My project is compiled as Unicode. And I also used the spy++ and it shows the Windows Proc is Unicode.
I am testing Chinese on Windows 7 with English Locale, so I also installed the Chinese Language Pack for my machine and it doesn't help either.
I could not explain what I see here. It would be appreciated if any one could shed some lights on this or how to debug further.
It turns out that it is due to the RichEdit control there. If I just use a text box, the Chinese characters would be displayed correctly along with other English characters. So after doing some reading, particular this one, I gave some tries and I got it working. So basically I should not use SetDlgItemText, instead I should use the following code (where m_strDisplay is the text to display on rich edit):
::SendMessage(hWndText, EM_AUTOURLDETECT, TRUE, NULL);
SETTEXTEX TextInfo = {0};
TextInfo.flags = ST_DEFAULT|SF_UNICODE;
TextInfo.codepage = 1200;
SendMessage(hWndText, EM_SETTEXTEX, (WPARAM)&TextInfo, (LPARAM)(LPCTSTR)m_strDisplay);
to set the text on RichEdit control.