Sign in to follow this  
BaneTrapper

SFML2.0 minimize / lost focus problems

Recommended Posts

BaneTrapper    1531
Hello.
I am currently trying to add alt+tab functionality while ingame and fullscreen to perform "minimize",
also if screen loses focus invoke same behaviour.

What i am trying to achieve is when user wants to alt tab, or clicks away from the application,
to hide application and only to be shown at "taskbar" also when holding alt and pressing tab to be visible(when using windows)

I have successfully edited my game to handle this, but the window is still up and not minimized as i wish.

Question the first:
How to hide application window, but be able to see it at "task bar"? (how to invoke minimize on window with code)

Question the second:
When i start application, its not shown at "taskbar" until 5-30 seconds pass, any way to speed up this?

Question the third:
When alt tab is pressed, is there a way to get this event in sfml2.0. If not, what is a way to invoke "minimize" when alt tab is pressed?

Any help is appreciated.

Share this post


Link to post
Share on other sites
BeerNutts    4401
I think you should ask this in the [url="http://en.sfml-dev.org/forums/index.php"]SFML forums[/url]. They are pretty good about answering these kind of questions and I'm sure there's a solution to your problem.

Share this post


Link to post
Share on other sites
BaneTrapper    1531
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.
[quote]
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};[/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this