|
|
Title | Determine the keyboard's locale |
Description | This example shows how to determine the keyboard's locale in Visual Basic 6. It uses API functions to determine the keyboard type. The HowTo tells how to change the keyboard type. |
Keywords | locale, language, internationalization |
Categories | Software Engineering, Windows |
|
|
Thanks to Chris Wagg.
Periodically a timer uses the GetKeyboardLayout API function to get the keyboard's layout. It then uses the GetLocaleInfo function to figure out what language the keyboard is set for.
|
|
Private Sub Timer1_Timer()
' Display KeyBoard Locale
' (this is great code to put on a status bar!)
Dim r&
r = GetKeyboardLayout(DWL_ANYTHREAD) '0&
If r <> KBLayout Then
KBLayout = r
r = Val("&H" & Right(Hex(r), 4)) ' lower 16bits
Dim strng$, buffer As String * bufsize
r = GetLocaleInfo(r, LOCALE_SLANGUAGE, buffer, _
bufsize - 1)
strng = buffer
If Label1.Caption <> strng Then
Label1.Caption = strng
End If
End If
End Sub
|
|
To change the keyboard locale while the program is running, open the Control Panel and run the Keyboard applet. Select the Language tab, click the Add button, and follow the instructions. After you have installed another language, you can decide what keyboard combination (LeftAlt-Shift, Ctrl-Shift, or None) lets you switch between languages.
The file KBLocale.txt contains some very interesting information on locales.
|
|
|
|
|
|