Windows 7 Capturing an obscured DirectX window

#1
I am looking for a way or capturing a screenshot of a DirectX application, even when the application's window is partially or completely hidden by other windows. Basically a PrintWindow() for DirectX.

I searched all around the internet and the closet I found was the below two posts, they discuss a way to do this in Vista, but the source code doesn't work on Win7.

I also tried a bunch of screen capture programs (Camtasia, etc.) but could not find one which will capture a hidden DirectX window, so I am not sure if this is even possible without alot of extra work.

Thanks!

Jer's One Stop Shop > Home - Vista DWM Hacking

C# – Screen capture with Vista DWM (Shared Direct3D Surface)
 


#2
Welcome to windows7forums. :)

You can't with PrintWindow(), it won't do however hard you try. Instead, you could capture the entire desktop with GetDC(NULL) and then crop it to the WPF/D3D app window. On 7 with the DWM, you could try the DWM thumbnail API.
 


#3
cybercore,

Thanks for posting. Unless I am misunderstanding, your first idea (using GetDC()) will not work because it will only capture visible portions of the window - the kicker here is that I need to capture hidden portions as well.

As for the DWM thumbnail API, I am actually trying to make a custom thumbnail so I am using DwnSetIconicThumbnail(). In order to do that I need to take a snapshot or DirectX content (as a bitmap, etc.) and then add some custom content, and finally call DwnSetIconicThumbnail(). I don't see how the other thumbnail APIs (DwnRegisterThumbnail, etc.) would help in this task.
 


#5
reghakr,

Thanks for the response. To clarify, what I mean by a hidden window is one that has another application's window on top of it. For example, if you open Windows Media Player, the entire window is visible. But if you then open Notepad and drag the Notepad window so that it is blocking the left half of the media player window, I need to capture the entire media player window, including the left side which is blocked by the Notepad window.
 


reghakr

Essential Member
#6
Can't you simply minimize or move the Notepad windows out of the way?

Am I missing something here?
 


#7
reghakr,

Since I am trying to make draw a custom thumbnail in Windows 7, I need to support the case where the window is partially/fully obscured, but the user moves their cursor down to the taskbar icon, which pops up the preview if running Aero. I cannot move around the windows because that would disturb their viewing experience. Windows already shows a proper taskbar preview for obscured windows, but I am making a dynamic one which has additional content in it.
 


reghakr

Essential Member
#8
Could you provide a screen shot so I can better understand?
 


#9
Here is a screenshot, in which Win 7's native taskbar preview is showing the entire WMP screen, even though part of it is covered by calc. In order to make a custom preview, I need a way of capturing this 'hidden' part of the WMP DirectX window.
 


Attachments

reghakr

Essential Member
#10
I really don't understand why you need another program on top of WMP

It makes no sense to me.

Could you explain why?
 


#11
To simplify things a bit - I am creating something like WMP that uses DirectX, and needs to be able to work with Win7 Taskbar preview, like in the screenshot. If someone loads up my app, and then loads Calc (or any other app), and covers my app - which is perfectly natural and happens all the time in windows - I need to able to show a proper preview. The issue is I am adding graphic content to my preview, so I need to make a custom one. Which leads to the original problem, how to get a screenshot of the obscured DirectX surface.
 


reghakr

Essential Member
#12
Are you a programmer?
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.