Find which MFC child window will get a mouse click

So, I have a plugin for the MFC program. I use the mouse event hook (from SetWindowsHookEx) to capture clicks. A host application can have any number of (possibly overlapping) child windows, but I only want to intercept clicks in a specific child window.

Is there a way to calculate in hook proc which of the child windows will handle the click? I suppose this is something like listing all the child windows looking at the Z-order, but I am very unfamiliar with the MFC / Win32 libraries, and I cannot find a good discussion on how to list all the children and figure out what the top one is.

+3
source share
2 answers

Maybe the function WindowFromPointis suitable for the account?

Returns the handle to the window containing the specified point.

The documentation does not explicitly mention ordering Z, but I can assure you of the first-hand experience that โ€œcontainsโ€ implicitly means that no other window is in front.

There are still a few of them with a slightly different behavior: ChildWindowFromPoint, ChildWindowFromPointExand RealChildWindowFromPoint.

+3
source

I have been involved with MFC for a long time, but I think HitTest is the term you are looking for. A quick trawl through MSDN indicates that most windows have a HitTest function that returns information about a specific point.

0
source

Source: https://habr.com/ru/post/1746234/


All Articles