How do you detemine that a window is being displayed?

How do you detemine that a window is being displayed?

Post by TGVlQ29tcG » Thu, 29 Nov 2007 06:47:00


I have a diagnostic application that takes screenshots of IE and sends them
back to me. If IE is minimized, it finds the window and restores it by
calling ShowWindow(hWnd, SW_RESTORE );. It can then find the window's
rectangle and grab the bitmap from the screen.

However, it may take some time for the window to actually draw itself. So,
I'd like my app to wait until then to take the screenshot.

My question is, how do I know when the window is actually visible?

I've tried calling:
- IsWindowVisible(hWnd);
- IsWindowEnabled(hWnd);
- GetWindowPlacement()
- GetWindowRect()

All of these indicate that the window is restored and at the correct size
and position right after I call ShowWindow(). But, clearly, the window is in
the middle of restoring.

I'm thinking of hooking the IE window and waiting for WM_WINDOWPOSCHANGED,
but that seems awfully complex. It seems like there should be a simpler
solution.

Any clues would be appreciated.

Thanks,
Lee J.
 
 
 

How do you detemine that a window is being displayed?

Post by Kellie Fit » Thu, 29 Nov 2007 11:20:58

On Nov 27, 1:47 pm, LeeCompete < XXXX@XXXXX.COM >



Hi,

You can use the following APIs to determine whether a window
or part of a window is covered/obscured:

GetDC()

GetClipBox()

GetClientRect()

ReleaseDC()

Also, you can use the following APIs to Get/Set/Determine whether
your window is the foreground window:

GetForegroundWindow()

SetForegroundWindow()

LockSetForegroundWindow()

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

http://www.yqcomputer.com/

Kellie.

 
 
 

How do you detemine that a window is being displayed?

Post by TGVlQ29tcG » Fri, 30 Nov 2007 05:26:00

Hi Kellie,

Thanks for the advice! Unfortunately it did not solve my problem. All of
the functions you mentioned return values before the window is fully
displayed so when I perform the screen capture I get the portion of the
screen that the window will occupy.

I did not mention that I am using Vista. It has an animation when a window
opens, although I don't think that should make a difference.

Thanks again!
Lee J.
 
 
 

How do you detemine that a window is being displayed?

Post by Um9i » Sat, 01 Dec 2007 01:24:00


Think like an accessibility app:
http://www.yqcomputer.com/

An app can find when the window has been shown, but there is no guarantee
that the application has finished drawing (what if it is animating?).