Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Minimizing application on alt+tab keypress  (Read 4306 times)

0 Members and 1 Guest are viewing this topic.

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Minimizing application on alt+tab keypress
« 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.
« Last Edit: November 28, 2012, 02:58:17 pm by BaneTrapper »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Minimizing application on alt+tab keypress
« Reply #1 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
Laurent Gomila - SFML developer

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: Minimizing application on alt+tab keypress
« Reply #2 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.
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Minimizing application on alt+tab keypress
« Reply #3 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: Minimizing application on alt+tab keypress
« Reply #4 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};
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: Minimizing application on alt+tab keypress
« Reply #5 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.
« Last Edit: November 28, 2012, 02:59:49 pm by BaneTrapper »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

 

anything