The problem (switching language dynamically) is solved with ActivateKeyboardLayout, but it still remains when i dynamically create a component on the form ( for ex. TEdit ). When this component gets into focus, the language changes to default. I tried use again ActivateKeyboardLayout, after creating the components, but it did not worked. Any ideas ?
Asked
Active
Viewed 2,155 times
4
-
Did you use KLF_SETFORPROCESS? – Ondrej Kelle Mar 10 '11 at 09:09
-
@TOndrej: I used it like this: LoadKeyboardLayout(someId, KLF_ACTIVATE) – dzibul Mar 10 '11 at 09:19
-
Cannot duplicate, my dynamically created Edit preserves the changed layout. Can you post a sample that have the problem? – Sertac Akyuz Mar 10 '11 at 17:47
-
@Sertac Akyuz: I have a dbgrid on the form. When I create the Edit dynamically I set the parent to dbgrid. The initial call of LoadKeyboardLayout is onActivate. – dzibul Mar 10 '11 at 18:42
-
4I think your problem is related with a known problem. See the QC report #79485: [Keyboard layout swtching when exiting dbgrid control](http://qc.embarcadero.com/wc/qcmain.aspx?d=79485). And see [this thread](https://forums.embarcadero.com/thread.jspa?messageID=180475&tstart=0#180475) on embarcadero forums for a workaround. – Sertac Akyuz Mar 10 '11 at 20:10
3 Answers
1
Your problem may be similar to this question.
Otherwise this code does it:
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_SHIFT, 0, 0, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0 );
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);

Community
- 1
- 1

Majid Shamkhani
- 849
- 2
- 8
- 28
-
1This code switches to next input language (and only if the default shortcuts have not been changed). It won't help if you have more than two input languages – Sertac Akyuz Apr 25 '12 at 14:31
1
at first you have to use "Windows" then you can use this method: ActivateKeyboardLayout(EnglishLayoutHandle, KLF_ACTIVATE) you can change "EnglishLayoutHandle" for any lang you want

Mehdei
- 245
- 1
- 4
- 10
0
On the Console application use
HWND handle = GetForegroundWindow();
PostMessage(handle, WM_INPUTLANGCHANGEREQUEST,
0, (LPARAM)HKL_NEXT);

Pazel1374
- 218
- 3
- 14