'Пример из API-Guide (модифицированный)
Const KL_NAMELENGTH As Long = 9
Const KLF_ACTIVATE As Long = &H1
Const LANG_RU_STD = "00000419"
Const LANG_NL_STD As String = "00000413"
Const LANG_EN_US As String = "00000409"
Const LANG_DU_STD As String = "00000407"
Const LANG_FR_STD As String = "0000040C"
Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long
Private Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal flags As Long) As Long
Public Function SetKbLayout(strLocaleId As String) As Boolean
On Error Resume Next
Dim strLocId As String
Dim strMsg As String
Dim lngErrNr As Long
strLocId = String(KL_NAMELENGTH, 0)
GetKeyboardLayoutName strLocId
If strLocId = (strLocaleId & Chr(0)) Then
SetKbLayout = True
Else
strLocId = String(KL_NAMELENGTH, 0)
strLocId = LoadKeyboardLayout((strLocaleId & Chr(0)), KLF_ACTIVATE)
If IsNull(strLocId) Then
SetKbLayout = False
Else
strLocId = String(KL_NAMELENGTH, 0)
GetKeyboardLayoutName strLocId
If strLocId = (strLocaleId & Chr(0)) Then
SetKbLayout = True
Else
SetKbLayout = False
End If
End If
End If
End Function
Private Sub Form_Load()
SetKbLayout LANG_RU_STD
MsgBox "Russian - RU!"
'Английский
SetKbLayout LANG_EN_US
MsgBox "English - US!"
End Sub
Private Declare Function ActivateKeyboardLayout Lib "user32.dll" (ByVal HKL As Long, ByVal Flags As Long) As Long
Private Sub Form_Load()
'русский (Россия)
ActivateKeyboardLayout &H419, 0
MsgBox "Russian - Russia!"
'английский (США)
ActivateKeyboardLayout &H409, 0
MsgBox "English - USA!"
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3