Discussion:
Getting List of Visible Windows
(too old to reply)
William Gabriel
2004-09-16 17:31:12 UTC
Permalink
Hi All,

I am working on a problem that requires me to know whether or not any
part of a particular window is visible (even if it's like a one pixel
corner). In my misunderstanding, I thought that ::IsWindowVisible
would cover it, but it looks like that call just verifies that the
hWnd actually has a dialog box. I was able to take it a step further
and find out whether or not a window is minimized using
::GetWindowPlacement, but I really need to find out if a window is
visible or not (in other words, not completely covered by higher
z-order windows).

Is there some sort of API call that will determine this, or do I
actually have to trudge through and do the math (not trivial!) to
figure out if the window is visible/hidden?

Any insights, hints or comments are very welcome!

Thanks,
Bill
Jussi Jumppanen
2004-09-17 14:55:28 UTC
Permalink
I really need to find out if a window is visible or not (in other words,
not completely covered by higher z-order windows).
Is there some sort of API call that will determine this, or do I
actually have to trudge through and do the math (not trivial!) to
figure out if the window is visible/hidden?
Any insights, hints or comments are very welcome!
Given that you can find all the frame windows using a Win32
enumerate windows function and given that you can find then
find the size of each of these frame windows also using the
Win32 API that would mean you have the answer for two of the
three unknowns of this equation.

I read somewhere that the z-order is the return order of the
enunerated child list for a given parent window.

If this is indeed the case then all the variables of this
problem are known and it should be easy enough to hand code
a solution to this problem.

Jussi Jumppanen
Author of: Zeus for Windows (New version 3.93 out now)
"The C/C++, Cobol, Java, HTML, Python, PHP, Perl programmer's editor"
Home Page: http://www.zeusedit.com
Alex Blekhman
2004-09-19 15:48:54 UTC
Permalink
Post by William Gabriel
I am working on a problem that requires me to know whether or not
any part of a particular window is visible (even if it's like a one
pixel corner).
I found this in MSDN:
KB75236 - "HOWTO: Determine Visible Window Area When Windows Overlap"
William Gabriel
2004-09-20 15:16:26 UTC
Permalink
Post by Alex Blekhman
Post by William Gabriel
I am working on a problem that requires me to know whether or not
any part of a particular window is visible (even if it's like a one
pixel corner).
KB75236 - "HOWTO: Determine Visible Window Area When Windows Overlap"
Would you mind posting a link to the article? I can't find it when I
search for any of the keywords or even when I look for the KB article
number directly.

Thanks,
Bill
Jeff F
2004-09-20 15:19:41 UTC
Permalink
Post by William Gabriel
Post by Alex Blekhman
Post by William Gabriel
I am working on a problem that requires me to know whether or not
any part of a particular window is visible (even if it's like a one
pixel corner).
KB75236 - "HOWTO: Determine Visible Window Area When Windows Overlap"
Would you mind posting a link to the article? I can't find it when I
search for any of the keywords or even when I look for the KB article
number directly.
It shows up for me in both VC6 and VC71 msdn's when you search for the
entire quoted string.

Jeff F
Alex Blekhman
2004-09-20 15:50:48 UTC
Permalink
Post by William Gabriel
Post by Alex Blekhman
KB75236 - "HOWTO: Determine Visible Window Area When Windows
Overlap"
Would you mind posting a link to the article?
Hm.. I tried to search it and I can't found it, too. Seems that this
article exists only in shipped MSDN. Anyway, here it is:

--------------------------------------------------------
"HOWTO: Determine Visible Window Area When Windows Overlap"

PSS ID Number: 75236

Article Last Modified on 7/9/2000


--------------------------------------------------------
The information in this article applies to:


Microsoft Windows Software Development Kit (SDK)
Microsoft Win32 Software Development Kit (SDK)

--------------------------------------------------------

This article was previously published under Q75236
SUMMARY
There is no Windows API that reports the portion of an application's
window that is not obscured by other windows. To determine which areas
of the window are covered, it is necessary to walk through the window
list managed by Windows.

Each window that precedes the application's window is "above" that
window on the screen. Using the IntersectRect() function, check the
rectangle of the window with any windows above to see if they
intersect. Any window that is above the application's window and
intersects its window rectangle obscures part of the application's
window. By accumulating the positions of all windows that overlap the
application's window, it is possible to determine which areas of the
window are covered and which are not.
MORE INFORMATION
The following sample code demonstrates this procedure:
GetWindowRect(hWnd, &rMyRect); /* Get the window dimensions
* for the current window.
*/
/* Start from the current window and use the GetWindow()
* function to move through the previous window handles.
*/

for (hPrevWnd = hWnd;
(hNextWnd = GetWindow(hPrevWnd, GW_HWNDPREV)) != NULL;
hPrevWnd = hNextWnd)
{
/* Get the window rectangle dimensions of the window that
* is higher Z-Order than the application's window.
*/
GetWindowRect(hNextWnd, &rOtherRect);

/* Check to see if this window is visible and if intersects
* with the rectangle of the application's window. If it does,
* call MessageBeep(). This intersection is an area of this
* application's window that is not visible.
*/

if (IsWindowVisible(hNextWnd) &&
IntersectRect(&rDestRect, &rMyRect, &rOtherRect))
{
MessageBeep(0);
}
}

Keywords: kbhowto kbWndw kbWndwProp KB75236
Technology: kbAudDeveloper kbSDKSearch kbWin32SDKSearch kbWin32sSearch
kbWinSDKSearch
--------------------------------------------------------

Loading...