/* The answer to this one depends upon whether you wish to determine if the user can see your whole window, part of your window, or a specific point on your window. The last case is the simplest one: to determine if the user can see a specific point, you determine the screen coordinates of that point, call WindowFromPoint, and check to see if the handle returned from WindowFromPoint is the same as yours. If so, the user can see that point because its at the top of the Z Order. */ BOOL IsWindowCentreVisibleToUser (HWND hWnd) { BOOL bRetVal = FALSE; RECT rcWnd; POINT pt; if (IsWindow (hWnd)) { GetWindowRect (hWnd, &rcWnd); pt.x = rcWnd.left + (rcWnd.right - rcWnd.left)/2; pt.y = rcWnd.top + (rcWnd.bottom - rcWnd.top)/2; bRetVal = (WindowFromPoint (pt) == hWnd); } return bRetVal; } /* BUT - the down side of this simplistic solution is that WindowFromPoint doesn't return handles for disabled windows. Ack... so we need something better. Read on... */ /* Things get a little more complicated if we're talking about all or part of a window. Basically, the trick is to make the system do the work for you by using the clipping system. Take a look at the code below. */ #define IWVTU_FULL 1 #define IWVTU_PARTIAL 2 #define IWVTU_HIDDEN 3 #define IWVTU_ERROR 4 UINT IsWindowVisibleToUser (HWND hWnd) { UINT uRetVal = IWVTU_ERROR; int iClipRes; HDC hdcWnd; RECT rcWndClient; RECT rcWndClip; if (IsWindow (hWnd)) { hdcWnd = GetDC (hWnd); GetClientRect (hWnd, &rcWndClient); iClipRes = GetClipBox (hdcWnd, &rcWndClip); ReleaseDC (hWnd, hdcWnd); switch (iClipRes) { case NULLREGION: uRetVal = IWVTU_HIDDEN; break; case SIMPLEREGION: if (EqualRect (&rcWndClip, &rcWndClient)) uRetVal = IWVTU_FULL; else uRetVal = IWVTU_PARTIAL; break; case COMPLEXREGION: uRetVal = IWVTU_PARTIAL; break; default: uRetVal = IWVTU_ERROR; break; } } return uRetVal; }