Sign in to follow this  
Sean_Seanston

Any reason ALT might not work?

Recommended Posts

Using a windowed DirectX application, I can't get the ALT key to work. You're supposed to use the VK_MENU virtual key for Win32, right? Whenever I try to get something like ALT + T to do something it just results in an error beep. It just seems like the application isn't recognizing the ALT key. Is that normal for windowed applications because of Alt-Tab or something?

Share this post


Link to post
Share on other sites
In your WndProc function, you might be handling the WM_KEYDOWN message, but not handling WM_SYSKEYDOWN. The second one is what gets sent when the user is holding down Alt. (Docs).

The contents of the two messages are pretty much (maybe exactly?) the same, so in my switch block I just do this:


case WM_KEYDOWN:
case WM_SYSKEYDOWN:
// etc.



Ditto for WM_SYSKEYUP.

Share this post


Link to post
Share on other sites
if what pinacolada said does not work, then you may need to replace the call to TranslateMessage() in your main loop with something else. See the docs for that API. This is not trivial because the alt key is intended to be used in combination with other keys, which sounds like what you want anyway. In that case, why not create an accelerator table and only call TranslateMessage() when TranslateAccelerator() returns false like the docs say?

Share this post


Link to post
Share on other sites
Quote:
Original post by pinacolada
In your WndProc function, you might be handling the WM_KEYDOWN message, but not handling WM_SYSKEYDOWN.


Nice, it works now.

One question though: Is it possible to stop it from making that noise whenever Alt is used with another key? Is that something caused by being windowed perhaps?

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