简体   繁体   English

如何打印屏幕最小化的窗口?

[英]How can I print screen minimized windows?

How can I print screen minimized windows? 如何打印屏幕最小化的窗口? I believe it's possible, since Windows task-bar can create a preview of a window even if it is minimized. 我相信这是可能的,因为Windows任务栏可以创建窗口的预览,即使它被最小化。

这家伙设法完成你所追求的目标: http//www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick我知道这个问题真的很老了,但它仍然可以对某人有效。

I'm pretty confident that this is not possible, at least by an external application like yours. 我非常有信心这是不可能的,至少是像你这样的外部应用程序。 When an application window is minimized, the window cannot (and does not) receive WM_PAINT messages, meaning that it is impossible to ask the window to redraw itself while it is minimized (or, "take a picture of it"). 当应用程序窗口最小化时,窗口不能(也不会)接收WM_PAINT消息,这意味着在最小化时(或者“拍摄它的照片”)不可能要求窗口重绘自身。 This is a limitation (or a rule) of the Windows API. 这是Windows API的限制(或规则)。

The taskbar "gets around this" by displaying a cached image (which is the last snapshot the DWM took of the window before it was minimized) and so it is not in fact taking a current picture of the window. 任务栏通过显示缓存的图像(这是DWM在最小化之前拍摄的最后一个快照)来“绕过这个”,因此它实际上并没有拍摄窗口的当前图片。 You can test this by running an application which periodically updates itself, and then minimizing it -- you will see that the preview image will not be updated until it is restored. 您可以通过运行定期更新自身的应用程序进行测试,然后将其最小化 - 您将看到预览图像在恢复之前不会更新。

The only way you could get around this is to do what the taskbar does -- periodically take a picture of the window you want, and when it is minimized, use the cached image instead. 解决这个问题的唯一方法是执行任务栏的操作 - 定期拍摄所需窗口的图片,并在最小化时使用缓存图像。 Of course, this means your app will have had to have been following the target window some time in advance (this obviously won't work if the first time you want to take a snapshot of the window is while it is minimized). 当然,这意味着您的应用必须提前一段时间跟踪目标窗口(如果您第一次想要拍摄窗口的快照,那么这显然不会起作用)。

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

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