阅读:1953回复:3
wince下按键驱动中怎么获取窗口当前选中项的句柄?
自己用GPIO做了的键盘,模拟标准键盘的上下左右,wince下用
PostMessage(hWndFrgd, WM_KEYDOWN, VK_DOWN, 0); PostMessage(hWndFrgd, WM_KEYUP, VK_DOWN, 0); 往上层发消息,其中hWndFrgd是通过HWND hWndFrgd = GetForegroundWindow();获取当前窗口的句柄,但是选中窗口里的项目(如下拉菜单)按键无响应,消息已经收到的,可能是获取句柄的函数不正确,请问怎么获取窗口当前选中项的句柄? |
|
沙发#
发布于:2007-01-04 12:13
hWnd
[in] Handle to the window whose window procedure is to receive the message. Two values have special meanings. Value Description HWND_BROADCAST The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows. The message is not posted to child windows. 试一下PostMessages(HWND_BROADCAST,......); |
|
板凳#
发布于:2007-01-06 08:39
谢谢zhengshijie兄,用HWND_BROADCAST试了一下,在窗口的菜单栏可以按键可以作相应的操作,但因为是广播的方式,会出现多个菜单或窗口都有响应,而且像桌面上的图标还是没有像标准键盘的方向键那样选择项目,在文本框中也没有实现按键输入字母。
|
|
地板#
发布于:2007-01-06 09:51
请用keybd_event发送键盘事件,不需要关心最上层窗口是谁,系统会自动发给当前的焦点窗口
按下发送:keybd_event( VK_LEFT, 75, KEYEVENTF_SILENT, 0 ); 松开发送:keybd_event( VK_LEFT, 75, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0 ); |
|