gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

OffTopic > Windows: Capturing a hidden window

#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.

#119588 - sgeos - Sat Feb 24, 2007 2:25 pm

Why do you want to do this? I don't see any advantages.

-Brendan

#119605 - tepples - Sat Feb 24, 2007 6:12 pm

It could be to emulate the effects of Mac OS X or Windows Vista Aero without requiring an OS or hardware upgrade.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#119638 - HyperHacker - Sat Feb 24, 2007 11:25 pm

The main reason is I want some of the features of an OpenGL window system (transparency/translucency without increased CPU usage, Z axis rotation, scaling, colour tinting etc) without the bloat many have (actual 3D window placement, X/Y axis rotation, thick windows, fancy spinning cube desktops, etc) and without having to switch to Vista or Linux. (I'll likely switch to Linux eventually, after upgrading this craptastic system to one that can actually run Ubuntu, but that could take a while. I am NOT using Vista and I doubt it'd run on this hardware, at least at any decent speed.)

I wonder if it's possible to hook into the window system and pretty much take Windows' out of the picture entirely...
_________________
I'm a PSP hacker now, but I still <3 DS.

#119667 - keldon - Sun Feb 25, 2007 4:11 am

Well this is much easier to do in linux, but it is possible in windows some how - maybe start off with a skin for x-blinds, is there an open source equivalent?