As the title says, I'd like to capture an image from a minimized window... is that even possible? I use the CaptureAnImage from msdn and it works, unless the window is minimized.
One solution I tried was maximizing it, capturing the image, then returning it to it's original state. Only problem is the animation looks ugly and I'd like to find an alternative... Here is how I tried it:
WINDOWPLACEMENT wInfo;
UINT originalPlacement;
GetWindowPlacement(hWnd, &wInfo);
originalPlacement = wInfo.showCmd;
wInfo.showCmd = SW_MAXIMIZE;
SetWindowPlacement(hWnd, &wInfo);
wInfo.showCmd = originalPlacement;
CaptureAnImage(hWnd); // Capture the image while it's maximized
SetWindowPlacement(hWnd, &wInfo);
So here I'm looking for one of these solutions:
Would it be possible to capture the image even while it's minimized?
or
Would it be possible to maximize it, capture it, then return it to it's original state without showing any kind of animation?
PS: I found that link while searching for my problem, but it's in c# and I'm unable to make it work in c++...
You cannot capture a minimized window, you MUST restore it first. But you can optionally restore it off-screen, or with an alpha opacity of 1, so the user does not see it but the OS will. And be sure to temporarily disable the restore/minimize animations as well, using
SystemParametersInfo(SPI_SETANIMATION)
(only do so ifSPI_GETANIMATION
reports animations are enabled), to reduce the time needed to show and then re-hide the window.For example: