Screenshots of closed / minimized windows

I have the following code to take screenshots of a window:

HDC WinDC;
HDC CopyDC;
HBITMAP hBitmap;
RECT rt;

GetClientRect (hwnd, &rt);
WinDC = GetDC (hwnd);
CopyDC = CreateCompatibleDC (WinDC);

hBitmap = CreateCompatibleBitmap (WinDC,
 rt.right - rt.left, //width
 rt.bottom - rt.top);//height

SelectObject (CopyDC, hBitmap);

//Copy the window DC to the compatible DC
BitBlt (CopyDC,   //destination
 0,0,
 rt.right - rt.left, //width
 rt.bottom - rt.top, //height
 WinDC,    //source
 0, 0,
 SRCCOPY);

ReleaseDC(hwnd, WinDC);
ReleaseDC(hwnd, CopyDC);

This is some kind of elses code, slightly modified, since I am not very familiar with DC and how windows draw material for the screen.

When I have one window slightly covering the other, the coverage window appears in the screenshots of the covered, which is kind of inconvenient. In addition, when the window is minimized, this code does not cause anything interesting.

Is there any way around this? I would suggest that taking screenshots with a minimal application would be quite difficult, but I hope that getting screenshots from closed windows is possible. Perhaps there is another way to implement this to get around these problems?

+3
source share
1

, - , . , , , , . , . WM_SYSCOMMAND + SC_RESTORE SetForegroundWindow() . , .

WM_PRINT , . . , . , WM_PRINT .

+4

Source: https://habr.com/ru/post/1737399/


All Articles