Microsoft KB Archive/75236

{|
 * width="100%"|

HOWTO: Determine Visible Window Area When Windows Overlap

 * }

Q75236

-

The information in this article applies to:


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

-

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 &quot;above&quot; 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); }   } Additional query words:

Keywords : kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin kbWndw kbWndwProp

Issue type : kbhowto

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWinSDKSearch