Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get the keyboard input language Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
14-Apr-04
Category
Win API
Language
Delphi 5.x
Views
114
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Lou Adler

When my application starts, I need to switch the keyboard language to Greek. 
Currently I use the statement ActivateKeyboardlayout(0, 0). When I need to switch 
to English (when the application terminates) I execute the same statement one more 
time. This works fine, but only if the language before the application's execution 
is English. So, before the call of the statement, I need to know if the language is 
Greek or English. How can do this?

Answer:

I usually use the following cycle:

1   { ... }
2   GetKeyboardLayoutName(@t);
3   y := string(t);
4   repeat
5     ActivateKeyboardLayout(HKL_NEXT, 0);
6     GetKeyboardLayoutName(@t);
7     x := string(t);
8   until
9   ((x = y) or (x = '00000405'));
10  { ... }


Using this, the English keyboard will give the KeyboardLayoutName '00000409' and 
the Greek one the '000000408'. These are standard language identifiers. They're the 
same on any Windows machine.

To display the information, you could use this little trick:

11  { ... }
12  var
13    kbd: array[0..2] of Char;
14  begin
15    GetLocaleInfo(loWord(GetKeyboardLayout(0)), LOCALE_SENGLANGUAGE, kbd, 2);
16    Form1.Caption := kbd;
17    { ... }


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC