问题描述
我正在开发触摸屏应用程序.该应用程序的目标是当最终用户要在具有 Windows7 的触摸屏设备上的屏幕上进行垂直触摸移动(用手指画一条垂直线)时,所有活动窗口都需要最小化(类似于显示桌面).我的问题是如何处理在桌面上活动的每个窗口中随处发生的所有 WM_TOUCH 消息.没有可以用来接收所有 WM_TOUCH 消息的 Windows 挂钩.我尝试使用 WH_GETMESSAGE 希望我可以提取 WM_TOUCH 消息但不起作用,我尝试使用 WH_MOUSE_LL 并获得所有鼠标事件.有一个函数 GetMessageExtraInfo ,我可以使用此代码从何处启动鼠标消息:
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:
如果 ((GetMessageExtraInfo().ToInt32() & MOUSEEVENTF_FROMTOUCH) == 0xFF515700){textBoxLog.AppendText("asdada");}如果这是真的,那么消息由 TouchScreen 设备启动.这仅适用于从我的应用程序(我的应用程序活动窗口)发送的消息,但不适用于我从应用程序窗口外的其他窗口获取的鼠标消息.我正在研究这个主题一段时间,但我仍然无法得到任何答案.因此,如果有人知道如何将所有 WM_TOUCH 消息发送到我的应用程序,请回复.
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.
米哈伊尔
推荐答案
你必须 hook 全局消息 proc.这样,您是第一个收到所有消息的人.您这样做的方式将不起作用,因为您的 wndproc 仅在您的窗口处于活动状态时才活动".
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.
只需创建一个新的 wndproc,它只处理您希望成为全局的消息,并根据您想要的逻辑允许它们通过或切断它们.
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
这篇关于从每个窗口获取 WM_TOUCH 消息并在我的 APP 中处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!