有熟悉输入法编程的吗?

mbctb 2010-09-07 05:23:31
我们知道,输入法最主要的是一个DLL,里面有这样两个导出函数:

7、BOOL ImeProcessKey( //处理应用程序传入的所有击键事件,监测是否是当前输入法所需的
HIMC hIMC, //应用程序句柄
UINT uVirKey, //需处理的虚键
DWORD lParam, //击键消息参数
CONST LPBYTE lpbKeyState //当前键盘状态(256字节)
)

11、UINT ImeToAsciiEx( //转换编码称汉字(串)
UINT uVirKey, //虚键
UINT uScanCode, //扫描码
CONST LPBYTE lpbKeyState, //用户定义的键盘状态
LPDWORD lpdwTransBuf, //转换后的数据存放区
UINT fuState, //活动菜单标志
HIMC hIMC //当前的应用程序句柄
)

在ImeProcessKey中,可以根据lParam来判断是按下键的消息还是松开键的消息。可是在ImeToAsciiEx中呢?有办法判断是按下键还是松开键的消息吗?
...全文
57 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mbctb 2010-09-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lazy_2010 的回复:]
lpbKeyState 这个数组的数值不可以吗?


MSDN 说


lpKeyState
[in] Pointer to a 256-byte array that contains the current keyboard state. Each element (byte) in the array contains the state of one key. If the……
[/Quote]
哦,对,这个是可以。根据虚拟键值找到那个键,再查这个“按键状态数组”,查到这个键是按下的还是松开的。对对对。

可是,如果第二个函数里的扫描码要是lParam就好了,因为lParam中就包含了扫描码,并且还包含了更多的信息。
lazy_2010 2010-09-07
  • 打赏
  • 举报
回复
lpbKeyState 这个数组的数值不可以吗?


MSDN 说


lpKeyState
[in] Pointer to a 256-byte array that contains the current keyboard state. Each element (byte) in the array contains the state of one key. If the high-order bit of a byte is set, the key is down (pressed).
The low bit, if set, indicates that the key is toggled on. In this function, only the toggle bit of the CAPS LOCK key is relevant. The toggle state of the NUM LOCK and SCROLL LOCK keys is ignored.

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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