扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
′以下的API函数用于输入法操作 Private Declare Function GetKeyboardLayoutList Lib ″user32″ _ (ByVal nBuff As Long, lpList As Long) As Long Private Declare Function ImmGetDescription Lib ″imm32.dll″ _ Alias ″ImmGetDescriptionA″ (ByVal hkl As Long, _ ByVal lpsz As String, ByVal uBufLen As Long) As Long Private Declare Function ImmIsIME Lib ″imm32.dll″ (ByVal hkl As Long) As Long Private Declare Function ActivateKeyboardLayout Lib ″user32″ _ (ByVal hkl As Long, ByVal flags As Long) As Long Private Declare Function GetKeyboardLayout Lib ″user32″ (ByVal dwLayout As Long)As Long 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 Const KLF_REORDER = &H8 Private NoOfKBDLayout As Long, i As Long, j As Long Private hKB(24) As Long, BuffLen As Long Private Buff As String Private RetStr As String Private RetCount As Long Private kln As String Private Sub Command1_Click() If Combo1.ListIndex = -1 Then′如果用户尚未选择输入法,显示出错信息 MsgBox ″请先选择一个输入法″ Exit Sub End If ′改变输入法顺序 kln = String(8, 0) ActivateKeyboardLayout hKB(Combo1.ListIndex), 0 res = GetKeyboardLayoutName(kln) res = LoadKeyboardLayout(kln, KLF_REORDER) ActivateKeyboardLayout hCurKBDLayout, 0 End Sub Private Sub Form_Load() Buff = String(255, 0) hCurKBDLayout = GetKeyboardLayout(0) ′取得目前的输入法 NoOfKBDLayout = GetKeyboardLayoutList(25, hKB(0)) ′取得所有输入法 ′ReDim layoutlist(NoOfKBDLayout) As String For i = 1 To NoOfKBDLayout If ImmIsIME(hKB(i - 1)) = 1 Then ′中文输入法 BuffLen = 255 RetCount = ImmGetDescription(hKB(i - 1), Buff, BuffLen) RetStr = Left(Buff, RetCount) Combo1.AddItem RetStr Else RetStr = ″English (American)″ ′英文输入法 Combo1.AddItem RetStr End If Next ActivateKeyboardLayout hCurKBDLayout, 0 ′恢复原来的输入法 End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者