如何打印屏幕最小化窗口?
如何打印屏幕最小化窗口?我相信这是可能的,因为即使窗口最小化,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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这家伙设法做到了你所追求的: http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick
我知道这个问题确实很老了,但对某人来说仍然有效。
This guy managed to do exactly what you are after: http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick
I know this question is really old, but it can still be valid for someone.
我非常有信心这是不可能的,至少对于像您这样的外部应用程序来说是不可能的。当应用程序窗口最小化时,该窗口不能(也不会)接收 WM_PAINT 消息,这意味着不可能要求窗口在最小化时重绘自身(或“为其拍照”)。这是 Windows API 的限制(或规则)。
任务栏通过显示缓存图像(这是 DWM 在窗口最小化之前拍摄的最后一个快照)来“解决这个问题”,因此它实际上并不是拍摄窗口的当前图片。您可以通过运行一个定期自我更新的应用程序来测试这一点,然后将其最小化——您将看到预览图像在恢复之前不会更新。
解决此问题的唯一方法是执行任务栏的操作 - 定期拍摄所需窗口的图片,并在窗口最小化时使用缓存的图像。当然,这意味着您的应用程序必须提前一段时间跟随目标窗口(如果您第一次想要拍摄窗口快照是在窗口最小化时,这显然不起作用)。
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"). This is a limitation (or a rule) of the 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. 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).