I have a requirement to develop an application that will capture the screenshots of any open window. So if that window is overlappedby some other window partially or fully, is it technically possible to take its screenshots? If yes, the how?
Thanks in Advance
AdeelFriday, March 19, 2010 4:53 AM
Get the handle to the window.
You could use WindowFromPoint or EnumWindows for this.
Then get the handle to the device context of the window.
You could use GetDC for this.
You can then save the device context for capturing it.
Look at the following link -
Microsoft MVP (Visual C++)Friday, March 19, 2010 10:49 AM
> I have a requirement to develop an application that will capture the screenshots of any open window. So if that window is
> overlappedby some other window partially or fully, is it technically possible to take its screenshots?Generally, no. Parts of windows obscured by other windows are not being rendered, so there are no actual pixels to capture. The information necessary to produce an image exists only in internal data structures of the application.Now, some windows might respond to WM_PRINT or WM_PRINTCLIENT messages, and render themselves to an HDC of your choice. The problem with this is that HDC is process-specific and cannot be passed across process boundaries. So you would have to inject some code into the other application's process that would create an in-memory HDC, send WM_PRINT[CLIENT] message to the window, then somehow transfer the resulting bitmap back to your application. All doable, but a lot of work (and, again, not all windows actually respond to those messages, so this work may be in vain).
Igor TandetnikFriday, March 19, 2010 12:22 PM