Jump to content
  • Advertisement
Sign in to follow this  
mtemple

F10 Key Pauses Direct3D Apps

This topic is 4018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Like I'm sure many have done, we based our Direct3D application on code from a tutorial. In fact much of it is based on the book "Beginning DirectX 9" by Wendy Jones. Now that we are much further along, I notice that the F10 key pauses the application. And now I notice that all of the samples from the book have the same problem. I have screwed around with the message handler, but I don't seem to be able to make the behavior go away. I tried looking at other example Direct3D code, but I have yet to find an example (that does not use DXUT) where the F10 key does not exhibit that same problem. Any ideas on how to fix this? I need to use the F10 key for other things, so I can't have this overriding my code! Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Are you sure F10 isn't configured as your "break into debugger" key? Or some other key intercepted by your development environment, or otherwise translated by your OS or third party software?

Share this post


Link to post
Share on other sites
The F10 key is a special system key that activates the window's menu. It is possible to override this (DevStudio for example). When the menu is activated, normal message loop processing is suspended which is probably what is causing the pause. DefWindowProc handles the F10 key and sends a WM_SYSCOMMAND / SC_KEYMENU message. So, don't call DefWindowProc is you get a WM_KEYDOWN for the F10 key, or handle the SC_KEYMENU message.

Skizz

Share this post


Link to post
Share on other sites
Thanks for your thoughts guys!

The simplest solution was to handle the SC_KEYMENU message and return zero like so:

case WM_SYSCOMMAND:
switch( wParam )
{
case SC_KEYMENU:
return(0);
break;
}
break;

It's surprising how many of the example and tutorial projects fail to do this, but I'm sure you'll notice it the first time you try to use the the F10 key, like to activate an in-game menu. It's especially important to those of you who are using Direct Input since the F10 keydown will act really strange and make you question your programming abilities.

This was really annoying...thanks to both of you for taking the time to reply!

Share this post


Link to post
Share on other sites
But if you return 0 you still can't use that key for something else
(i think the same situations is for R/L alt keys).
Is there solution for this?

Share this post


Link to post
Share on other sites
Hmmm. Actually, I never had any problem with using F10 for something else (to display a menu in my case). But my background scene was freezing up whenever the menu appeared. So when using return(0), it solved my problem because it stopped Windows from processing the F10 key after I had (using Direct Input).

I wouldn't think you should have any problem with using the F10 in this manner as long as you were handling the F10 keypress before Windows does. At worst, you could process the click right before sending the 'return(0)'.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!