DirectInput Keyboard problem and WM message question

Started by
-1 comments, last by SmoothRide 15 years, 4 months ago
My issues seem to come in pairs so once again I am going to try to kill two birds with one stone. I am using VS2005, C++, win32 app, and directx 9 for my project. 1. I set up my DX keyboard object and it's working fine however there is one caveat. When I run the program in full screen mode everything is good. I can navigate away from the app window, go back to it and the keystrokes are getting captured. In window mode though, it starts out fine, but if I switch focus to another window and go back then my keystrokes are not getting captured by the app anymore. I have the cooperative level set to DISCL_FOREGROUND|DISCL_NONEXCLUSIVE. Curiously, when I set it to DISCL_BACKGROUND|DISCL_NONEXCLUSIVE then the keyboard works fine in windowed mode even after navigating away and back though obviously it keeps capturing keystrokes even when the app is not in focus - so it's not ideal. I also have the D3DERR_DEVICELOST and D3DERR_DEVICENOTRESET events coded for device cooperative level so that when it's lost objects are released and reacquired (including the keyboard). It works fine for full screen mode, but it doesn't look like windowed mode even causes these events. Any ideas what can I try to reacquire the keyboard in window mode? 2. Another problem is that I've been trying to get my app to quit when the "X" icon on the window title bar is clicked. From what I gather I need to put exit logic in either WM_CLOSE or WM_DESTROY event. Here's what I am seeing though. WM_CLOSE is not called at all when my window closes (it's the only window and it has no parent) and WM_DESTROY for some reason is invoked right at the beginning of program execution. As far as I can tell I am only creating the window once in my code so I don't understand why WM_DESTROY gets triggered. The effect is that the window pops up for a second and the program quits right away when I put PostQuitMessage under WM_DESTROY case. Any ideas on this one?

This topic is closed to new replies.

Advertisement