Advertisement

ALT +TAB , if you know please help

Started by January 12, 2004 05:23 PM
7 comments, last by lazork357 21 years, 1 month ago
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.
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.





"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
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?
---------------
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]
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
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...
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
Advertisement
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?
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.
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.

This topic is closed to new replies.

Advertisement