F10 Key Pauses Direct3D Apps

Started by
4 comments, last by mtemple 16 years, 7 months ago
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!
Mark TempleEnemy Technology"We have found the enemy, and he is us!"
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?
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
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!
Mark TempleEnemy Technology"We have found the enemy, and he is us!"
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?
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)'.
Mark TempleEnemy Technology"We have found the enemy, and he is us!"

This topic is closed to new replies.

Advertisement