Why does a MFC Dialog ding?
-
I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging. My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings. I think once I fix the dinging, I'll be happy. Thanks in Adavance
-
I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging. My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings. I think once I fix the dinging, I'll be happy. Thanks in Adavance
In order to use SetFocus() in OnInitDialog(), you need to return FALSE from the OnInitDialog() function (as it says in the comment at the bottom of the function) You can also trap key events in PreTranslateMsg function.
-
I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging. My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings. I think once I fix the dinging, I'll be happy. Thanks in Adavance