# Alt pauses game

## Recommended Posts

__ODIN__    479
We're going through alpha-testing at the moment, and one reported bug is that pressing ALT pauses the game when in windowed mode. What actually seems to happen is that pressing ALT triggers the system menu (WS_SYSMENU); if you go on to press down, for example, you'll get the system menu expanding. I can't find a way to trap that behaviour, and creating a window without WS_SYSMENU means I don't get minimize/maximize/close window buttons neither. Anyone have any ideas? Allan

##### Share on other sites
MasterWorks    496
I too would like to know the answer to this. Especially if somebody has a Visual Basic solution.

##### Share on other sites
__ODIN__    479
I suspect it's related to setting some combination of flags at creation, so it should work for both C++ and VB.. but doesn't look as if anyone's seen the problem before :(

##### Share on other sites
S1CA    1418
When you press Alt to get the menu bar, you'll first get a WM_SYSKEYDOWN message with the code of any key that was pressed at the same time (which is how common accelerators such as Alt-F work).

Usually your window procedure will then pass this message on to DefWindowProc() which depending on which system key combination was pressed will in turn issue a WM_SYSCOMMAND or call TranslateAccelerator() (which itself will issue menu related messages).

If you look at the documentation for WM_SYSKEYDOWN, you'll see it says "An application should return zero if it processes this message." - returning 0 instead of calling DefWindowProc() tells Windows "I've handled this, so no further processing is required".

Some code:
LRESULT MyWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ){  // some sort of system key combination?  if (Msg==WM_SYSKEYDOWN)  {    // was Alt pressed?  Bit-29 of lParam is documented as:    // "The value is 1 if the ALT key is down while the key is pressed"    if (lParam & (1<<29))    {      // yep, Alt was pressed so tell Windows to stop all further       // processing of this message.      return 0;    }  }  // ...other window message handling goes here...  // we *didn't* handle this message, so let Windows do it  return DefWindowProc( hWnd, Msg, wParam, lParam );}

NOTE: of course, if you do have a menu on your window, you should not do the above since you're taking away important accessibility functionality from your application (inconsistent UIs on the desktop degrade the whole user experience for everyone - don't do it unless you absolutely need to do it! [anyone from the ICQ team reading?...])

Quote:
 but doesn't look as if anyone's seen the problem before :(

patience, patience! - the question has been up for less than a day...

##### Share on other sites
__ODIN__    479
Thanks for the heads up S1CA; and 1 day is usually enough for a topic to disappear out of sight and out of mind :) Pros and cons of a high-traffic website!

##### Share on other sites
Quote:
 Original post by __ODIN__Thanks for the heads up S1CA; and 1 day is usually enough for a topic to disappear out of sight and out of mind :) Pros and cons of a high-traffic website!

To quote the forum FAQ:
Quote:
 And possibly most importantly: Nobody here is being paid to help you. Be polite and courteous, and you're more likely to get help.. If you posted a thread and people haven’t replied to you, don’t bump it until at least 24 hours have passed with no replies.

Good luck.