#119565 - HyperHacker - Sat Feb 24, 2007 10:26 am
I'm looking for a way to capture the content of a window in Windows XP (e.g. take a screenshot of the window), without having that window actually on the screen. I've tried a number of methods, and none work well:
-WM_PRINTCLIENT: The program that created the window has to implement this; just about nothing does, not even Microsoft's (and their API documentation says you should -_-).
-Move the window off-screen: I get a black square.
-Minimize it: Black square.
-Hide it (remove WS_VISIBLE style): I get the area behind it.
-Put it always on top at 0% opacity: Works, but quite a hack, not really useable. Trying to use opacity with an OpenGL window gives me BSODs. Also, I suspect Windows is using up a fair bit of CPU power to apply translucency effects to these windows.
-Force it to be behind some other window: I get the window it's hidden behind.
The opacity method is interesting; apparently it's done at a very low level, so any attempts to read the image give you a fully opaque image. Also, mouse events completely ignore a pixel whose opacity is 0%, so having the window always on top and 0% opaque lets you grab shots of it while it's seemingly not there at all. However, this is a major hack; I suspect the mouse events being ignored is a bug (I've certainly never seen it documented), and OpenGL + translucency = boom.
It seems like using GetDC() and BitBlt() is not the way to go, as this just ends up reading from the screen bitmap itself - you can see this by using dimensions larger than the window, it's literally as if you took a shot of the entire screen and cropped it to this size. Is there some other way to do this?
If you're wondering, I'm looking to basically implement my own window system "overtop of" the existing one. So I'll have a full-screen window displaying the contents of other windows while actually being above them. Has anyone done this?
_________________
I'm a PSP hacker now, but I still <3 DS.
-WM_PRINTCLIENT: The program that created the window has to implement this; just about nothing does, not even Microsoft's (and their API documentation says you should -_-).
-Move the window off-screen: I get a black square.
-Minimize it: Black square.
-Hide it (remove WS_VISIBLE style): I get the area behind it.
-Put it always on top at 0% opacity: Works, but quite a hack, not really useable. Trying to use opacity with an OpenGL window gives me BSODs. Also, I suspect Windows is using up a fair bit of CPU power to apply translucency effects to these windows.
-Force it to be behind some other window: I get the window it's hidden behind.
The opacity method is interesting; apparently it's done at a very low level, so any attempts to read the image give you a fully opaque image. Also, mouse events completely ignore a pixel whose opacity is 0%, so having the window always on top and 0% opaque lets you grab shots of it while it's seemingly not there at all. However, this is a major hack; I suspect the mouse events being ignored is a bug (I've certainly never seen it documented), and OpenGL + translucency = boom.
It seems like using GetDC() and BitBlt() is not the way to go, as this just ends up reading from the screen bitmap itself - you can see this by using dimensions larger than the window, it's literally as if you took a shot of the entire screen and cropped it to this size. Is there some other way to do this?
If you're wondering, I'm looking to basically implement my own window system "overtop of" the existing one. So I'll have a full-screen window displaying the contents of other windows while actually being above them. Has anyone done this?
_________________
I'm a PSP hacker now, but I still <3 DS.