1
votes

So, I've run into a problem while trying to take a picture of a window located in an inactive desktop using the PrintWindow API and it is starting to get on my nerves.

The problem is that with a specific window, even though PrintWindow succeeds and I get the image of the window I want, that image is always an outdated copy of the last time the desktop was active. At first I thought the window was not receiving any input, but after some checking I noticed that it still receives and processes input, but does not render any changes until its desktop gets activated again. I tested in Windows 7 and 10, and that only happens in Windows 10.

After some more checking, I found out that the main window in fact updates itself just as expected and it is its child, which covers all the client area of the main window, who is to blame. The 2 windows were created with the following styles:

Class Styles: 0x00000003 = CS_VREDRAW | CS_HREDRAW

Parent Extended Styles: 0x00000000

Parent Standard Styles: 0x96000000 = WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS

Child Extended Styles: 0x00000020 = WS_EX_TRANSPARENT

Child Standard Styles: 0x56300000 = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_HSCROLL | WS_VSCROLL

I have already tried an absolutely uncountable amount of things trying to get this problem solved, and I've searched the web extensively, all to no avail. I am so frustrated that I am well ready to give up if noone can at least come up with an explanation for this.

1
What do you mean by "inactive desktop"?user7860670
Not enough programmers write a message handler for WM_PRINTCLIENT. Easy to do, they just don't think of it. That makes it hard to implement PrintWindow() correctly. The workaround is undocumented, but I'd imagine that the backing bitmap that Aero creates would be useful. With the hangup that it no longer gets updated when the desktop is not active. Something like that.Hans Passant
@VTT A desktop that is not the one who is currently visible to the user.Tray
@HansPassant What do you mean by "the backing bitmap that Aero creates"? My next try would be to implement my own WM_PRINT/WM_PRINTCLIENT on behalf of the window, even though I'm not completely familiar of how this is done and also because I think thats not the problem here, as all the windows that do not process PrintWindow correctly normally just return an empty bitmap instead of an outdated one.Tray

1 Answers

0
votes

Windows does not render windows that are not visible. You are getting the current image, which is the same image you would get when getting the little preview window when hovering over the task bar icon.
Without the program itself explicitly calling the render function the window will not update. It's not going to be possible to get a screenshot of how the window would currently look if it updated.