Archived

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

Mythar

Windows ALT-TAB

Recommended Posts

Guest Anonymous Poster
TO my knowledge, I don''t think you can. This quetions comes up every 2 weeks or so. No one has ever posted source code that actually works. That "make it think your game is a screen saver" trick doesn''t work. And I''ve never found a windows message you can intercept to stop ALT-TAB. shurg, maybe someone will finally post the correct method....

Share this post


Link to post
Share on other sites


The solution regarding the screen saver doesn''t work as mentioned:

//: from help file ..
UINT nPreviousState;

// Disables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);

// Enables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);

..at least on my NT 4.0 machine.

However, there is an alternative solution that seems to work just fine:

//: sometime during window creation
RegisterHotKey(hwnd, 0x01, MOD_ALT, VK_TAB);

//: before app exits
UnregisterHotKey(hwnd, 0x01);

-mordell


Share this post


Link to post
Share on other sites
Well, I am sure there are ways to disable ALT-TABBING, but to tell you the truth, do you really want to? The whole purpose of windows is to allow multiple programs to run simultaneously. What if users need to ALT-TAB out of your app every so often (I know I have done it in the past). One other thing, is that if you ever plan to release a commercial app, wether it be a game or not, you must adhere to certain standards (set by MS and others), or else your app will be marked as incimpatable. You know that ''Designed for Windows x.x'' logo. You won''t get that unless you follow the standards.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yeah, don''t disable it. I like this solution better!


case WM_ACTIVATEAPP:
is_active = (BOOL)wParam;

// see ya!
if(!is_active)
PostQuitMessage(0);

return 0;

Share this post


Link to post
Share on other sites
Yes, it is better, if you don''t disable it, but there is a way of doing it... remove the WinMSG-stuff from your code (PeekMessage/TranslateMessage/DispatchMessage/...) and return 0 instead of msg.wParam. But Ctrl-Alt-Del will B disabled, too

Share this post


Link to post
Share on other sites