views:

1084

answers:

3

How should I tell SDL to maximize the application window?

I'm creating the window with these flags: SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE.

Thanks for your replies

A: 

There are additional environment variables that can be set to control the display window. Unfortunately the sdl docs are down at the moment, so I can't look up what you need.

Peter Shinners
Souds promising, but I could not fin anything like that in the documentation.
CommanderZ
I had a look at the env. variables once again, and there are none affecting the status of the window, only position.
CommanderZ
A: 

SDL_FULLSCREEN is the option you're looking for:

flags |= SDL_FULLSCREEN;
screen = SDL_SetVideoMode(..., flags);
MattyT
I'm looking for a way how to maximize the window, not make it fullscreen.
CommanderZ
Sorry, my bad - that'll teach me for working on these issues when I'm half asleep! I'll try and come up with a solution that *maximises* the screen tonight.
MattyT
+3  A: 

This functionality is controlled by the window manager when you use the SDL_RESIZABLE flag. To simulate the maximizing a window with SDL you would need to first determine the size the window would occupy when maximized. Then you would call SDL_SetVideoMode with this size after placing the window with the SDL_VIDEO_WINDOW_POS environment variable.

If you truly need the window to be maximized as if you had clicked on the maximize button, then you will have to access the underlying window manager directly (i.e. SDL won't help you).

For example, the ShowWindow function can be used to maximize a window using the Win32 API. To get a handle to the window created by SDL use the SDL_GetWMInfo function. The resulting SDL_SysWMinfo struct contains a window field of type HWND. This must be passed to the ShowWindow function along with the SW_MAXIMIZE flag.

SDL_SysWMinfo info;
SDL_GetWMInfo(&info);
ShowWindow(info.window, SW_MAXIMIZE);
Judge Maygarden
This is justa simultion, not the real thing. The real maximized window has no left and right border and the "minimize" icon instead of the "maximize" one in the header.
CommanderZ