Solved

Get Windows Current Input Locale

Posted on 1998-10-15
5
526 Views
Last Modified: 2006-11-17
My user is running US English version of Windows NT with several Input Locales (Keyboard languages) installed. How can I programmatically find out which Input Locale is current, and how my application can detect when the Input Locale changes. Using GetSystemDefaultLCID or GetSystemDefaultLangID APIs (no matter) I can only obtain the default Windows language, not the one currently in use.
0
Comment
Question by:tbbrhun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:tbbrhun
ID: 1440141
Edited text of question
0
 
LVL 2

Expert Comment

by:Poddy
ID: 1440142
The function you seek is GetKeyboardLayout

Pass zero as its parameter (indicating current thread)

the low word is the input language locale
the hi word is the physical layout
(these may be the same)
0
 

Author Comment

by:tbbrhun
ID: 1440143
Poddy, can you be a little more specific about the low and high words and how to work with them after the API executed. I'm not really getting the your answer, but it looks like you know what you are talking about. I'd like to hear more from you.
0
 
LVL 2

Accepted Solution

by:
Poddy earned 200 total points
ID: 1440144
dim lngRet as long
dim lngHi as long
dim lngLo as long

lngRet=GetKeyboardLayout(0)
lngHi=lngRet \ 65536
lngLo=lngRet mod 65536

specifically, the return value is a 4 byte value:
The high word is the first two bytes and the low word is the second pair.

So to extract the high word, divide the result by 65536 (2 ^16)
and to extract the low word, take the remainder (MODulo) of this division.  

So if you set up a keyboard with US Language in British layout, the return values will be 2057 in the high word and 1033 in the low word.

2057 (&H0809)is the locale ID for British English
1033 (&H0409)is the locale ID for US English


any questions...?
0
 

Author Comment

by:tbbrhun
ID: 1440145
Hey Poddy! By the time I got it I figured it out myself, but you get your points anyway, THANKS. That solves half of my problem. Now, is there any way to detect in my application when the user changes the locale. I would spend another 100 point for that. Please respond to BDH4628@ix.netcom.com. If you have the solution, I will re-submit the question through Exchange for you to get points. THANKS again!!!!!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question