SFML community forums

Help => Window => Topic started by: Vicker on June 05, 2013, 12:58:59 am

Title: Maximize Window
Post by: Vicker on June 05, 2013, 12:58:59 am
Is there a way to create a maximized window, or to tell a window to maximize?
Title: Re: Maximize Window
Post by: Nexus on June 05, 2013, 01:05:35 am
Fullscreen: Yes, see the window's constructor or create() documentation

Maximized: Yes, get the desktop resolution from sf::VideoMode and create window with corresponding size (keep in mind the borders and task bar)
Title: Re: Maximize Window
Post by: Vicker on June 05, 2013, 03:00:25 am
Fullscreen: Yes, see the window's constructor or create() documentation

Maximized: Yes, get the desktop resolution from sf::VideoMode and create window with corresponding size (keep in mind the borders and task bar)

Neither of those options are truly maximizing the window. 

The issue with the method of using sf::VideoMode to get the desktop size is that it ignores the size of task bars and title bars.  This ends up creating a window that is too big.  A correctly maximized window fills up most of the screen, but leaves room for the task bars and the window's title bar.

Fullscreen doesn't work for my purposes.  I need a maximized window, not a fullscreen window.
Title: Re: Maximize Window
Post by: Laurent on June 05, 2013, 07:52:34 am
No, there's no way with SFML.
Title: Re: Maximize Window
Post by: Vicker on June 05, 2013, 10:00:06 pm
No, there's no way with SFML.

That's a shame.  Out of curiosity, is maximizing a window in some way more difficult than the other options that sfml does provide? 

I can probably come up with a kludge for my program by maximizing a gtk+ window, measuring it, and then using its dimensions to set the size of the sfml window, but that's certainly not the most elegant solution.
Title: Re: Maximize Window
Post by: Laurent on June 05, 2013, 10:08:27 pm
Quote
Out of curiosity, is maximizing a window in some way more difficult than the other options that sfml does provide?
No, it's just a choice ;)

SFML is not a dedicated windowing library, so it has a lot less features compared to GTK, Qt, wxWidgets, etc. However, maximizing a window is one of the options that might be added to SFML 2.
Title: Re: Maximize Window
Post by: Phanoo on July 11, 2017, 07:43:54 pm
still not done what a surprise
Title: Re: Maximize Window
Post by: Hapax on July 11, 2017, 07:57:08 pm
still not done what a surprise
SFML 2 provides access to the window's OS handle now so you should be able to use (simple?) OS-specific functions to maximise an SFML window.
Title: Re: Maximize Window
Post by: Phanoo on August 31, 2017, 10:16:50 am
I know, but it should be added, window minimizing/maximizing are basic functions for any lib that does  windowing, nothing that advanced... doing it os-specific breaks the purpose of using sfml
Title: Re: Maximize Window
Post by: Rosme on August 31, 2017, 02:25:03 pm
To quote Laurent:
SFML is not a dedicated windowing library...

Further more, nothing prevents you from doing it and making a pull request. You have to remember that the people that works on the library are doing in their own free time. Any help from the community is welcomed.
Title: Re: Maximize Window
Post by: Drifty Pine on August 10, 2018, 07:11:49 pm
Hi, I was interested in maximizing/minimizing my window and found this thread. I realize this thread is a year old, but since no example was given and it is so simple on MS-Windows, I thought I would show the code to save anyone who needed to do it some time.

First include the windows header:

#include <windows.h>


Create your window with sf::Window or sf::RenderWindow as usual:

sf::RenderWindow window{sf::VideoMode{window_width, window_height}, "My Window Title"};


Then call the MS-Windows O/S ShowWindow() function to change the window state to maximized:

::ShowWindow(window.getSystemHandle(), SW_MAXIMIZE);


Also, there is a detailed and active discussion about adding various window state changing functionality to SFML that can be found here:
https://en.sfml-dev.org/forums/index.php?topic=23578.0 (https://en.sfml-dev.org/forums/index.php?topic=23578.0)