Capturing a Window

JChild 21 Reputation points
2022-04-05T16:10:43.833+00:00

I am trying to capture an application's display and stream it to another computer. The application is composed of multiple program windows. I found the following examples and used them to create a window with a composition host that captures multiple windows and combines them into one window.

https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/tree/master/cpp/ScreenCaptureforHWND

https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/tree/master/cpp/HelloComposition/HelloComposition

When I try to capture the new window I am only able to get the new window's background color. I have tried using GDI+ (StretchBlt and BitBlt) and DirectX but they are unable to capture the new window with the combined layers. They just capture the background of the new window. The code I am writing is on a stand alone network so I am unable to post the actual source code.

Windows development Windows API - Win32
Developer technologies C++
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2022-04-08T19:29:02.79+00:00

    I tested with HelloComposition sample, and I can copy the window with
    PrintWindow and PW_RENDERFULLCONTENT flag (into a compatible DC with CreateCompatibleDC)
    I added a SS_BITMAP Static control where I set the copied bitmap with STM_SETIMAGE :

    191454-printwindow.gif

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.