Satyajit
Satyajit

Reputation: 533

Given x,y point, how to get window handle for a control which is NOT present on the foreground window?

I know that the WindowFromPoint can be used to obtain a handle to the control if that control resides in a visible window. My requirement is to get the control details, even if the application's window is not in the foreground (it is not minimised, just that it can be behind another window). Is there a WINAPI function available which can do this for me?

If not, can someone suggest an approach as to how I can go about doing this, falling short of: 1. Enumerating all the controls in a particular background window, 2. then getting their bounds, 3. and then comparing if those bounds contain the x,y coordinate?

Upvotes: 3

Views: 1804

Answers (2)

Dan Byström
Dan Byström

Reputation: 9244

You're looking for the GetWindow API function which can be used to enumerate all windows and then the GetWindowRect function.

Upvotes: 2

user
user

Reputation: 6947

Maybe WM_NCHITTEST can help? See for example WM_NCHITTEST is for hit-testing, and hit-testing can happen for reasons other than the mouse being over your window over at The Old New Thing.

The WM_NC­HIT­TEST message doesn't mean that the mouse is in your window; it just means that somebody is asking, "If the mouse were in your window, what would it be doing?"

Upvotes: 0

Related Questions