开发者

Get window handle on which mouse button was clicked

Hey, I'm using Windows Hook, I installed the mouse hook, system-wide and its working perfectly. Now there is a problem, I need to the get window handle on which the mouse was clicked.. How do I do that? Does the Mouse hook event p开发者_运维技巧asses us that information?


Since you're using WH_MOUSE_LL, you're making a low-level mouse hook, which actually receives a pointer to a MSLLHOOKSTRUCT that doesn't have an hwnd member.

You need to set a normal mouse hook using WH_MOUSE; you'll then get a pointer to the MOUSEHOOKSTRUCT that you're expecting..


Use the WindowFromPoint function to get the window under a given location.


Assuming you set a WH_MOUSE hook, your MouseProc receives a pointer to a MOUSEHOOKSTRUCT struct. Since the hwnd member is NULL, you could try using WindowFromPoint with the pt member of the struct. The pt member is the coordinate at the time the message was created.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜