开发者

WindowFromPoint returns handle for controls, but I only want the main window

开发者 https://www.devze.com 2023-02-01 11:53 出处:网络
I\'m writing a window spy type thing to add a feature to an application I have. I\'ve got all the code working, but sometimes WindowFromPoint returns a handle for a control instead of the containing w

I'm writing a window spy type thing to add a feature to an application I have. I've got all the code working, but sometimes WindowFromPoint returns a handle for a control instead of the containing w开发者_JS百科indow. For my purposes, I am only concerned with the main containing window. Is there a way for me exclude controls? Or possible detect that the result is a control and recurse upward until I reach the containing window?


You can test for the WS_CHILD flag (GetWindowLongPtr with 'GWL_STYLE') and if it's there call GetAncestor with 'GA_ROOT' as 'gaFlags'.

0

精彩评论

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

关注公众号