I played with the Windows DWM APIs to see if I can capture external windows with them. I created a small C ++ program that creates a window, captures an external HWND, associates an external HWND with my window, and successfully displays external data. The API works great in this situation.
Now I'm trying to figure out if I can capture the bit data that appears in my own window. I realized that since I have ownership of this window, there must be a way.
My goals
To capture DWM content rendering in my own window into a bitmap. This should work whether my window is in the foreground or in the background.
My test case
In my test case, I have a YouTube video in your external window. I put it in the background and allowed the video to display in the foreground in my application window. From there, I will try to use the methods below to capture the contents of my window.
Capture attempts
Bitlt
I tried using BitBlt to capture the contents of windows into a bitmap. Whenever I try to do this, I just end up with the title bar of my window and none of the contents of the DWM thumbnails. However, if instead of getting DC for my window, I get DC for the whole screen and capture the coordinates of my window, I can get DWM rendering of the content. But if the window is in the background, it is obvious that I am not getting what I want.
Printwindow
PrintWindow . BitBlt, Windows, .
- DWM API? - WM_PAINT/WM_PRINT, ?