C++ - How to screen-capture, except for some windows C++ - How to screen-capture, except for some windows windows windows

C++ - How to screen-capture, except for some windows


In windows even the desktop is considered a window and has its own HWND.It seems however, not easily possible to only copy the "wallpaper" on its own.

So i basically see two ways to do that.1. Copy the entire desktop e.g. BitBlt(GetWindowDC(GetDesktopWindow()),...)

OR

  1. Use GetWindow and traverse the window list in backward direction starting from the Desktop-Window whose HWND you just can determine with GetDesktopWindow(), Like this:

    // paint on a black DChwnd=GetDesktopWindow()while (hwnd = GetWindow(hwnd, GW_HWNDPREV)) { // is this window not shared? continue // else bitblt it into our dc}

Hope i gave some inspiration :-)If someone knows a way how to copy ONLY the desktop without its child windows please let me know.


You can use Magnifier API.

There is a function in magnifier API that allows you to exclude specific windows from your target window (your window with 1x magnification where magnifier renders).

You can set this window to full screen and make it transparent and then use PrintWindow function.

The function: https://docs.microsoft.com/en-us/windows/desktop/api/magnification/nf-magnification-magsetwindowfilterlist

Sample projects:

https://www.codeproject.com/Articles/607288/Screenshot-using-the-Magnification-library

https://code.msdn.microsoft.com/windowsdesktop/Magnification-API-Sample-14269fd2


I think that to limit the capture content within a big window will be more simple. otherwise you will need to cut some windows from the screen capture.