Sign in to follow this  
__ODIN__

Alt pauses game

Recommended Posts

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 this post


Link to post
Share on other sites
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this