C++ How to get layered window content image?

RL Chen 210 Reputation points
2024-05-17T13:18:09.3866667+00:00

My goal is to get an HDC of an image or image of the contents of a layered window in Windows 7 and above.

I tried PrintWindow(hwndMag, hdcDest, PW_RENDERFULLCONTENT), but this requires Windows 8.1. Note that layered windows may contain transparency, or be obscured, and I need a solution that meets the above requirements, thanks!

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,881 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,455 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,571 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 82,206 Reputation points
    2024-05-17T14:05:13.5633333+00:00

    DwmRegisterThumbnail detects transparency

    It can de drawn on a background with a given color (then I used D3DXSaveSurfaceToFileInMemory in an old test to get the resulting bitmap bits, but not sure if it is necessary...)

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful