• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1141
  • Last Modified:

Capture hidden window

How to capture any hidden or partially visible window (SDI or MDI) from external process using its hWnd?
0
Bertiaux
Asked:
Bertiaux
  • 5
  • 4
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
try to use PrintWindow:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_6qpj.asp

But won't work with win95/98/xp
0
 
_corey_Commented:
Actually, you can just use the WM_PRINT message by itself.  This will work with all those versions of windows as long as the application doesn't dismiss the event.

Simply provide it a device context to draw on and you've got the image of the window.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_3qwk.asp ["WM_PRINT"]

corey
0
 
BertiauxAuthor Commented:
I have tested WM_PRINT message with MS Powerpoint: I do not get client area just borders and scroll bars.

Do you have any idea?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
_corey_Commented:
Yea, add some options to the lParam of the message.

PRF_CLIENT | PRF_NONCLIENT

Should get you the whole window.

corey
0
 
BertiauxAuthor Commented:
Even with these params, I just get nothing.
Is seems that some applications windows such as Powerpoint windows do not react to WM_Print.

The question seems to be the following : Is WM_Print acting on all kind of graphics or device?
Are there limitations?

Thanks
0
 
_corey_Commented:
The window does need to support the WM_PRINT call in its procedure.  

PowerPoint could have limitations on when it responds to these window (visible only, or in focus, or it has to convert the display it is using to printing using a special method).

PP is probably using a form of DirectDraw or Direct3D which is not performed directly on a device context but you could try adding child and other flags to the lParam to make sure.

corey
0
 
BertiauxAuthor Commented:
If a form of DirectDraw or Direct3D is used, what would then be the solution?

We have tried with all the params, including the one related to child and we just get external frame.

0
 
_corey_Commented:
The only way to get that image then would be to grab a copy of the front or back buffer in video memory using Direct3D.

corey
0
 
_corey_Commented:
Programmatically, you would use the http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/IDirect3DDevice9/GetFrontBufferData.asp ["IDirect3DDevice9::GetFrontBufferData Method"] call to get the best image.  Don't do this many times in a row as it requires a copy and can be slow.

corey
0
 
BertiauxAuthor Commented:
Thanks for the info,

We shall try and keep you posted.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now