Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

lazork357

ALT +TAB , if you know please help

This topic is 5328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I have the ALT+TAB work correctly? I want it to minimize my OpenGL application (made using NeHe BaseCode) when in fullscreen. I need the exact code, because I''ve already read about this in other threads but nothing seems to work and no-one seems to know exactly.

Share this post


Link to post
Share on other sites
Advertisement
You want Alt+Tab to terminate the application? Right.

Anyway, if you''re using NeHe''s basecode, just check if keys[VK_MENU] and keys[VK_TAB] are set at the same time and call PostQuitMessage(0) or exit(EXIT_FAILURE), or call your custom in-program clean-up wizard if you''re a proper coder.





Share this post


Link to post
Share on other sites
quote:
You want Alt+Tab to terminate the application? Right.


Why would he want that?

Anyway, what exactly does your program do NOW if someone presses ALT-TAB?

Share this post


Link to post
Share on other sites
Check for the WM_ACTIVATE message (look it up on msdn) and if your application gets deactivated (and you're in fullscreen mode), then minimize it with something like:
ShowWindow(window_handle, SW_MINIMIZE);

John B

[edited by - JohnBSmall on January 12, 2004 8:46:24 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In you WndProc, look for the WM_ACTIVATE message.

wParam is:
WA_ACTIVE - program is activated by some method other than a mouse click (e.g. ALT-Tab)

WA_CLICKACTIVE - activated by a mouse click

WA_INACTIVE - deactivated

lParam is the handle to the window being activated or deactivated.

Do whatever you need to do to minimize your window at that point...

Share this post


Link to post
Share on other sites
i think more generally you typically want to keep your game updating but don''t bother with your draw loop. so have alt-tab set a flag so you can do something like:


void Game::mainLoop()
{
update();

if (!isAltTabbed)
draw();
}


-mw

Share this post


Link to post
Share on other sites
Now my application does what it''s supposed to do when you''re running it and press alt+tab:
it shows the start bar but the screen settings (resolution...) don''t change and my program stays on top (and you can''t send it to the background).
Instead I want it to disappear, just like any game would do when you press alt+tab.
I knew I had to use WM_ACTIVATE and WA_INACTIVE, but what code should i put there?

Share this post


Link to post
Share on other sites
I think you''d need to make a ChangeDisplaySettings() to reset the previous resolution, then once WA_ACTIVE comes back in, use the same function with your stored settings. I''ll go try it in my own basecode and see how it works.

Share this post


Link to post
Share on other sites
I used the ChangeDisplaySettings() function and it seems to work.
I have to check it on differet computers but let''s hope it will be OK.
Thanks to everyone.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!