PrintWindow on inactive desktop in Windows 10

1

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.

c++
c
windows-10
asked on Stack Overflow Sep 26, 2017 by Tray • edited Sep 26, 2017 by Tray

1 Answer

0

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.

answered on Stack Overflow Sep 26, 2017 by xyious

User contributions licensed under CC BY-SA 3.0