|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
使用API编写自定义函数,可设置输入法状态。这是我找到的一段代码,需要配合窗体控件的相关事件(比如列表框单击事件)应用- Option Explicit
- '* ************************************************************** *
- '* 程序名称:modIME.bas
- '* 程序功能:用API控件输入法状态
- '* 作者:lyserver
- '* ************************************************************** *
- Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
- Private Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, lpList 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 Const KLF_SETFORPROCESS = &H100
-
- '打开或关闭中文输入法
- Public Sub SetImeMode(bMode As Boolean) 'True打开、False关闭
- Dim i As Long
- Dim hCurKB As Long
- Dim hKB() As Long, KBCount As Long
-
- hCurKB = GetKeyboardLayout(0) '获得当前输入法句柄
- If CBool(ImmIsIME(hCurKB)) <> bMode Then
- KBCount = GetKeyboardLayoutList(0, ByVal 0&)
- ReDim hKB(KBCount - 1)
- GetKeyboardLayoutList KBCount, hKB(0)
- For i = 0 To KBCount - 1
- If CBool(ImmIsIME(hKB(i))) = bMode Then
- ActivateKeyboardLayout hKB(i), KLF_SETFORPROCESS
- Exit For
- End If
- Next
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|