从每个窗口获取 WM_TOUCH 消息并在我的应用程序中处理
我正在开发触摸屏应用程序。该应用程序的目标是,当最终用户要在 Windows7 触摸屏设备的屏幕上进行垂直触摸移动(用手指画一条垂直线)时,所有活动窗口都需要最小化(例如显示桌面)。我的问题是如何处理桌面上每个活动窗口中随处发生的所有 WM_TOUCH 消息。没有 Windows 钩子可以用来获取所有 WM_TOUCH 消息。我尝试使用 WH_GETMESSAGE 希望可以提取 WM_TOUCH 消息,但不起作用,我尝试使用 WH_MOUSE_LL 并获取所有鼠标事件。有一个函数 GetMessageExtraInfo,我可以使用此代码从何处启动鼠标消息:
if ((GetMessageExtraInfo().ToInt32() & MOUSEEVENTF_FROMTOUCH) == 0xFF515700) { textBoxLog.AppendText("asdada"); } 如果这是真的,则该消息由触摸屏设备发起。这仅适用于从我的应用程序(我的应用程序活动窗口)发送的消息,但不适用于我从应用程序窗口之外的其他窗口收到的鼠标消息。我正在研究这个主题一段时间,但仍然无法得到任何答案。因此,如果有人知道如何将所有 WM_TOUCH 消息发送到我的应用程序,请回复。
米哈伊尔
I am developing touchscreen application. The goal of the application is when the end user is going to make vertical touch movement (a vertical line with his finger)on the screen on touchscreen device with Windows7 all of the active windows need to minimize (something like show desktop). My question is how can i process all the WM_TOUCH messages that happen everywhere in every window that is active on the desktop. There is no windows hook with which i can take all the WM_TOUCH messages. I tried to use the WH_GETMESSAGE with hope that i can extract the WM_TOUCH messages but is not working, I tried to use the WH_MOUSE_LL and got all the mouse events. There is function GetMessageExtraInfo with which i can see from where the mouse messages is initiated with this code:
if ((GetMessageExtraInfo().ToInt32() & MOUSEEVENTF_FROMTOUCH) == 0xFF515700)
{
textBoxLog.AppendText("asdada");
}
if this is true then the message is initiated by TouchScreen device. This works only with the messages that are sent from my app(my app active window), but not with the mouse messages i am getting from the other windows outside my app window. I am researching this subject for a while and i still can't get any answer. So please if someone knows any way how can i get all the WM_TOUCH messages to my app please respond.
Mihail
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须挂钩全局消息过程。这样您就可以第一个收到所有消息。您这样做的方式将不起作用,因为您的 wndproc 仅当您的窗口处于活动状态时才“活动”。
只需创建一个新的 wndproc,仅处理您想要全局的消息,并根据您想要的逻辑允许它们通过或切断它们。
http://msdn.microsoft.com/en -us/library/ms644990%28v=vs.85%29.aspx
You must hook the global message proc. This way you are the first to get at all the messages. The way you are doing this will not work because your wndproc is only "active" when your windows is active.
Simply create a new wndproc that processes only the messages you want to be global and either allowing them to pass through or cutting them off depending on the logic you want.
http://msdn.microsoft.com/en-us/library/ms644990%28v=vs.85%29.aspx
根据 Windows DevCenter 上的类似讨论 这似乎不可能:
According to a similiar discussion on Windows DevCenter this doesn't seem to be possible: