2
« on: February 03, 2010, 06:05:41 am »
Hi, I'm just making a little program that needs to do what it says in the topic title for some reason. When I say foreground window, I mean whatever was open before the program was run. Is this possible in SFML?
The code below creates a new window with the dimensions of the foreground window, but doesn't copy its contents (doesn't make the copy window appear, either), so the .png file that is created is full of random garbage instead of a copy of the window contents.
{
HWND hWindow = GetForegroundWindow(); //From <windows.h>
if(hWindow == NULL)
throw "Foreground window error";
RenderWindow window(hWindow, WindowSettings(24, 8, 0));
Image image = window.Capture();
image.SaveToFile("test.png");
}
Is there a way to make this work, or do I have to use OpenGL, Win32, or something like that to accomplish this?