tags:

views:

418

answers:

2

Is it possible to print screen minimized windows? I think it IS, because Windows's taskbar preview does do it. Thanks

(please correct my english errors)

A: 

I believe it would be. I'm not a C# guy, so I'm sure there's an easier way with the crafty managed functions, but here's some sample code if you were to go it in C: http://msdn.microsoft.com/en-us/library/dd183402(VS.85).aspx

omghai2u
It won't capture images of minimized applications.
TTT
+2  A: 

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).

GRB
See http://msdn.microsoft.com/en-us/library/aa969541%28VS.85%29.aspx to use the DWM functions that the taskbar uses.
Julien Lebosquain
Nice find, I had no idea that API existed (though it would only be of use on Vista or newer)
GRB
What happends if Windows Aero is disabled?
TTT
You will most likely get an error if you try to get a thumbnail when Aero is disabled (the taskbar for one loses the ability to show window thumbnails when Aero is off)
GRB