在程序运行时如何切换输入法

武汉星云信软件 2002-06-03 09:21:30
有一个客户提出了这样一个要求:
我的某一个window中有一个Datawindow, DW选择员工表,用来输入新加入的员工信息。客户要求在输入新员工的姓名时,自动切换到五笔输入法,再输入其他项目时,自动切换回英文输入法,请问该如何做到?
...全文
92 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
TO: jackygan
你也叫一剑飘香啊!SQL版的版主N_chow也叫一剑飘香咧,看来你也是高手啊!
jackygan 2002-06-04
  • 打赏
  • 举报
回复
哈哈,很好。
海洋‘s 2002-06-04
  • 打赏
  • 举报
回复
在程序中自动切换中英文输入法,将如何实现呢?

①定义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"

②脚本:
ulong hklCurrent
ulong hnd

//切换到英文输入法
hklCurrent=GetKeyboardLayout(0)
if ImmIsIME(hklCurrent) then
hnd=Handle(parent)
ImmSimulateHotKey(hnd,112)
end if

//切换到中文输入法
hklCurrent=GetKeyboardLayout(0)
if not ImmIsIME(hklCurrent) then
hnd=Handle(parent)
ImmSimulateHotKey(hnd,112)
end if

<对其它的两个API函数尚无资料,并似乎也好象不太好使,只是一种思路而已! →小木鱼>

[注]GetKeyboardLayout()函数

说明: 取得一个句柄,描述指定应用程序的键盘布局。
返回值: ulong,键盘布局的句柄。
参数 类型及说明
dwLayout ulong,欲检查的线程的标识符。
  • 打赏
  • 举报
回复
非常感谢各位的帮忙,待我回去试过后再与各位继续讨论
xiaoxianhe 2002-06-03
  • 打赏
  • 举报
回复
可按楼上ldy(罗大佑)的方法。
vtigerfox 2002-06-03
  • 打赏
  • 举报
回复
post message WM_INPUTLANGCHANGEREQUEST

detail search MSDN
dotnba 2002-06-03
  • 打赏
  • 举报
回复
//if ... then
// 需要中文输入的字段
// hklKeyboardLayout=GetKeyboardLayout(0)
// if not ImmIsIME(hklKeyboardLayout) then
// ImmSimulateHotKey(handle(parent),16)
// end if
//else
//// 英文输入字段
// hklKeyboardLayout=GetKeyboardLayout(0)
// if ImmIsIME(hklKeyboardLayout) then
// ImmSimulateHotKey(handle (parent),16)
// end if
//end if
mjh7781 2002-06-03
  • 打赏
  • 举报
回复
声明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

切换中文
constant int IME_THotKey_IME_NonIME_Toggle = 112
ulong hklcurrent
ulong hnd

hklcurrent = getkeyboardlayout(0)
if not ImmIsIme(hklcurrent) then
hnd = handle(parent)
ImmSimulateHotKey(hnd,IME_THotKey_IME_NonIME_Toggle)
end if
tiantianpb 2002-06-03
  • 打赏
  • 举报
回复
查查以前的帖子,有答案的

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧