win98下程序中自动控制切换中英文输入法
敬业的IT人
互联网
佚名
2008-1-4 11:42:43
问:在数据窗口录入数据时,有的域要输英文、有的域要输中文,每次要手工切换,很麻烦,能不能在程序中自动控制切换中英文输入法?
答:可以用API函数实现:
声明API函数:
function boolean ImmSimulateHotKey (ULong hWnd, ULong dwHotKeyID) library "IMM32.dll"
function ulong GetKeyboardLayout(ulong dwLayout) LIBRARY "user32.dll"
function boolean ImmIsIME(uLong hklKeyboardLayout) library "IMM32.DLL"
定义变量:
constant int IME_THotKey_IME_NonIME_Toggle=112
ulong hklCurrent
ulong hnd
切换到英文输入法:
hklCurrent=GetKeyboardLayout(0)
if ImmIsIME(hklCurrent) then
hnd=Handle(parent)
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle)
end if
切换到中文输入法:
hklCurrent=GetKeyboardLayout(0)
if not ImmIsIME(hklCurrent) then
hnd=Handle(parent)
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle)
end if
可根据需要,触发两段不同的脚本以达到动态切换中英文输入法的目的。
- 最新文章
- Windows映射模式及相关问题的解决[01-04]
- 不同版本的PB所需要的运行时动态链接库[01-04]
- 打印技巧:解决走纸、单位换算[01-04]
- 打印函数[01-04]
- 从Web站点读取Flash动画演播的PB6.5编程[01-04]
- 动态实现下拉数据窗口DDDW的设定[01-04]
- 相关文章
