|
-
July 28th, 2009, 11:20 AM
#1
Are any windows overlapping my window?
Say I have a handle to a window ("my" window). I would like to know if there are any other windows "on top" of it.
I think I can use EnumWindows and then GetWindowRect on each window and see if any overlap my window. If so, use WindowFromPoint to find out who is on top.
But this seems like a lot of work! Does anyone know an easier method?
Also, I think I remember seeing a Windows function to determine overlap (if any) of two windows, but I can't find it now. Is there such a function, or have I made that up? (I know I can do a mess of subtraction, but...)
-
July 28th, 2009, 01:07 PM
#2
Re: Are any windows overlapping my window?
I should qualify before I go on that I don't consider myself an expert on Windows API, though I've used it for years and at one time was more familiar with it, but I've happily let that go in favor of frameworks like Qt.
That said, I don't believe there is a function which specifically tells you if two windows overlap - you may be thinking of MFC or other framework's ability to to compare the rectangles take from two windows which can.
The GetNextWindow API may be the most useful to you (or it's MFC counterpart). With that, you should be able to walk through those windows who's Z order is on top of yours. While these may not all be obscuring your window, they are the only one's that could, and that minimizes your search population.
After that, it is going to be a matter of comparing the overlap of the window's rectangular region, though some windows could conceivably be non-rectangular in form, and if so, a simplification that assumes a bounding rectangle may occasionally return false positives unless you researched the entire bounding region.
These tests are fairly quick, probably faster than asking the API for the candidate windows in the first place.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).
-
July 29th, 2009, 06:25 AM
#3
Re: Are any windows overlapping my window?
i am new with APIs. so, i am not sure but may be you should check for GetRunningWindow () ... i hope it helps...
-
July 29th, 2009, 03:02 PM
#4
Re: Are any windows overlapping my window?
One thing that might help is to consider the z-order of the window. This will allow you to determine which windows are on top of your windows. That way you can ignore the ones below you.
Search google for "Window z-order enumwindows"
-
August 1st, 2009, 01:08 PM
#5
Re: Are any windows overlapping my window?
 Originally Posted by rexx
Also, I think I remember seeing a Windows function to determine overlap (if any) of two windows
Yes, it's a classic one (see on google groups, Win32 overlapping, same one than on 16-bits)
Last edited by carl666; August 1st, 2009 at 01:13 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|