SFML community forums

Help => General => Topic started by: BaneTrapper on November 28, 2012, 01:00:34 pm

Title: Minimizing application on alt+tab keypress
Post by: BaneTrapper on November 28, 2012, 01:00:34 pm
Hello.
I am trying to minimize the application window when user alt tabs.

I tried using void sf::Window::setVisible(bool visible)
but it hides drawing window but also hides from taskbar and user cant access it ever again.
also when in console it gives this "Failed to share openGL context"

Does sfml support this, or i most go OS specific function?
Also how to invoke the "Minimize" on a window using windows7?

EDIT::
The problem is fixed at 5th replay to this post(Scroll down), if your having problems go check it out.
Title: Re: Minimizing application on alt+tab keypress
Post by: Laurent on November 28, 2012, 01:07:53 pm
SFML doesn't provide the "minimize" function.

Quote
Also how to invoke the "Minimize" on a window using windows7?
I didn't know how to do it, but it took me 2 seconds to find with Google:
ShowWindow(handle, SW_MINIMIZE);
// use SW_RESTORE to restore it
Title: Re: Minimizing application on alt+tab keypress
Post by: BaneTrapper on November 28, 2012, 01:30:13 pm
took me 5,
But i am wondering does SFML have a function to do this.
And you answered no, Thanks on help.
Title: Re: Minimizing application on alt+tab keypress
Post by: Nexus on November 28, 2012, 02:22:37 pm
I am trying to minimize the application window when user alt tabs.
Note that this is not the usual behavior on Windows. Alt+Tab brings the window you select to the front and gives it focus, leaving others how they are.
Title: Re: Minimizing application on alt+tab keypress
Post by: BaneTrapper on November 28, 2012, 02:51:54 pm
After mayor fight with bugs here is how i done it.
Using "windows.h" and sfml events

Here is how i done it in a nutshell if anyone needs it.

when sf::Event::LostFocus is triggered i do following
if isFullScreen == true{save all data of window, create a new window that is not fullscreen "NOTE most update handle from window.h when you recreate a new window", limit frames per second to 1 to save process, and using windwos.h function ShowWindow(myWindow, SW_MINIMIZE), make infinite loop where games only handles 1 event "sf::Event::GainedFocus" }

else { limit frames per second to 1, make infinite loop where games only handles 1 event "sf::Event::GainedFocus}

when in this infinite loop the sf::Event::GainedFocus is triggered

if isFullScreen == true { recreate old window using data that was stored "NOTE most update handle from window.h when you recreate a new window" and use windwos.h function ShowWindow(myWindow, SW_RESTORE) to restore window to its previous location and info, turn off limit on FPS, break the infinite loop and go into game}

else{turn off limit on FPS, go intro normal game related stuff / break the infinite loop};
Title: Re: Minimizing application on alt+tab keypress
Post by: BaneTrapper on November 28, 2012, 02:56:12 pm
I am trying to minimize the application window when user alt tabs.
Note that this is not the usual behavior on Windows. Alt+Tab brings the window you select to the front and gives it focus, leaving others how they are.
Mhm... when am in "game" and i press alt + tab and select other window the "game" loses focus.
I am unsure where sf::Event::LostFocus gets its info from, but its triggered when alt + tab is pressed.