How to get a desktop screenshot without my application window? [modified]
-
Hi all. I am trying to create a simple magnifier application which follows the mouse and magnifies the portion around the mouse cursor. I know how to get a screenshot of a desktop. I have tried GDI way and DirectX9 Surface way, but DX surface is too slow for realtime capturing. So I am staying with GDI. The problem is - when I get a screenshot my magnifier application is included, too. I tried to GetNextWindow and GetFocus to get HDC only for the active window and then render HDC into memory DC. But it is a nightmare - some applications have multiple windows so I get only one of them and the other part of the shot is a mess (from previous shots). I guess it would be really hard to get DC for every window beneath my own and to combine all the DC images myself. Brrr... One approach could be to hide my app, capture screen, restore my app. But it is not suitable for realtime work. Of course, I know that Windows keeps track of window clipping regions so area behind my window would not be updated in other windows WM_PAINT. But I think I can force it to render if I use WS_EX_LAYERED style and 99% visibility for my app - then Windows invalidates area even behind my window. Of course, I can remove CAPTUREBLT flag from BitBlt when capturing and then I won't get my window because all layered windows would be ignored. But then I do not get any of the layered windows (like tooltips etc.). I know that Vista Magnification API can do the trick but it does not work on XP :(( So the problem is - how can I virtually "erase" my app from the screenshot and get area behind it? Thanks for any ideas.
modified on Friday, December 26, 2008 9:45 AM