Real hwnd from the point
When we use WindowFromPoint
winapi function we usually can get the case, when Point specifies to some control within a window. And in such cases WindowFromPoint
returns handle to that control, not to the window that handles that control.
For example in my small test application if I point to the "body" of chrome browser I get the control with class = Chrome_RenderWidgetHostHWND
and its hwnd.
But what I need is to get the "parent" window for tha开发者_Go百科t control (which is obviously should be the chrome window).
Traverse the parents using GetAncestor()
passing GA_PARENT
. This differs from calling GetParent()
which will return the owner if the window is a top-level window.
Can't you just use GetParent? Keep traversing until you find the desktop window.
精彩评论