简体   繁体   English

Windows 10中非活动桌面上的PrintWindow

[英]PrintWindow on inactive desktop in Windows 10

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. 因此,在尝试使用PrintWindow API拍摄处于不活动状态的桌面中的窗口的图片时遇到了一个问题,它开始引起我的注意。

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. 问题是,对于特定的窗口,即使PrintWindow成功并且获得了我想要的窗口的图像,该图像也始终是上次激活桌面时的过时副本。 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. 我在Windows 7和10中进行了测试,只有在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 | 类样式: 0x00000003 = CS_VREDRAW | CS_HREDRAW CS_HREDRAW

Parent Extended Styles : 0x00000000 父级扩展样式 :0x00000000

Parent Standard Styles : 0x96000000 = WS_POPUP | 父标准样式 :0x96000000 = WS_POPUP | WS_VISIBLE | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPCHILDREN | WS_CLIPSIBLINGS WS_CLIPSIBLINGS

Child Extended Styles : 0x00000020 = WS_EX_TRANSPARENT 子级扩展样式 :0x00000020 = WS_EX_TRANSPARENT

Child Standard Styles : 0x56300000 = WS_CHILD | 子标准样式 :0x56300000 = WS_CHILD | WS_VISIBLE | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CLIPSIBLINGS | WS_HSCROLL | WS_HSCROLL | WS_VSCROLL 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. 我非常沮丧,如果没有人至少可以对此做出解释,我已经准备好放弃。

Windows does not render windows that are not visible. Windows不会渲染不可见的窗口。 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. 如果没有程序本身显式调用render函数,则该窗口将不会更新。 It's not going to be possible to get a screenshot of how the window would currently look if it updated. 无法获得屏幕更新后的当前屏幕截图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM