Jump to content
  • Advertisement
Sign in to follow this  
gazsux

OpenGL DirectDraw Window Focus Function

This topic is 4862 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

Hey, I'm currently testing a network game that I created. However, whenever I load additional instances of the game and the focus of the game window is switched to a different instance of the game the first game seems to record key presses that arent being pressed at all. I was hoping that I could avoid this and simplify my testing by getting the game to ignore any key presses it thinks it is receiving when the game window is not in focus. Any idea if DX has the ability to check for window focus? I know OpenGL does. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
This simplest way to handle this would be to respond to the WM_ACTIVATE message. When wParam is WM_INACTIVE, set a flag indicating the application is inactive. When wParam is anything else, reset the flag. Then, all you have to do is check the flag before processing input/rendering/etc.

Share this post


Link to post
Share on other sites
Are you saying that you aren't pressing any keys on the keyboard and it is receiving WM_KEYDOWN/UP or WM_CHAR messages? Or are you using DirectInput? If you're using DI, be sure it is not in exclusive mode, or it will have exclusive access to the keys pressed even when it doesn't have focus.

DX specifically won't have a window focus function (at least I haven't used one if it does), you'll want to use Windows GDI for that. I can't tell you off the top of my head the name of the function, sorry.

Share this post


Link to post
Share on other sites
I am using DI but I am not pressing the keys or the key presses I do are in addition to the ones it thinks it is getting. I'll look into that exclusive mode thing as well as the WM_ACTIVATE.

Thanks!

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!