ALT key state after ModifyStyle, DoModal
-
I have a problem with the combination of
ModifyStyle
andDoModal
:ModifyStyle(0, WS_MINIMIZE, SWP_HIDEWINDOW); dlg_whatever.DoModal();
(only these both together pose the problem) at this point. i.e. after the subdialog ended withEndDialog
, the keyboard's ALT status is "toggled", even though the keyboard has not been touched all the time. This poses a problem for me, so I carry out aSetKeyboardState
, clearing the ALT status (testwise clearing the status of ALL keys too). This works so far, that a subsequentGetKeyboardState
showsn that the ALT key is not toggled any more. However, when any key gets pressed now,PreTranslateMessage
showsWM_SYSKEYUP
(i.e. ALT status). Does anyone know 1. the reason for this behaviour, 2. how to clear the ALT state more effectively than by SetKeyboardState? -
I have a problem with the combination of
ModifyStyle
andDoModal
:ModifyStyle(0, WS_MINIMIZE, SWP_HIDEWINDOW); dlg_whatever.DoModal();
(only these both together pose the problem) at this point. i.e. after the subdialog ended withEndDialog
, the keyboard's ALT status is "toggled", even though the keyboard has not been touched all the time. This poses a problem for me, so I carry out aSetKeyboardState
, clearing the ALT status (testwise clearing the status of ALL keys too). This works so far, that a subsequentGetKeyboardState
showsn that the ALT key is not toggled any more. However, when any key gets pressed now,PreTranslateMessage
showsWM_SYSKEYUP
(i.e. ALT status). Does anyone know 1. the reason for this behaviour, 2. how to clear the ALT state more effectively than by SetKeyboardState?I have trouble believing that ModifyStyle() will alter the Keyboard state. What makes you believe the Alt key status has been toggled? Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
I have trouble believing that ModifyStyle() will alter the Keyboard state. What makes you believe the Alt key status has been toggled? Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
As I posted, not ModifyStyle, nor DoModal, but these two in combination achieve that. In the meantime I found out, what's happening. I have to note, that I have noticed and tested this issue only in XP. Every time, when no control has the focus in the dialog, ALT mode will be entered - and that is happening after ModifyStyle, DoModal. I inserted a SetFocus() after DoModal, and the problem is cleared. Then I tested around, and found, that in other cases, when no control is focused on (for example, when the currently focused control becomed disabled), ALT mode will be entered. The ALT status was easy to notice, because a PreTranslateMessage handler processes certain Alt-key combinations, like AltReturn, AltRight, etc., and these functions showed up without having touched the Alt key before. Thanks anyway.
-
As I posted, not ModifyStyle, nor DoModal, but these two in combination achieve that. In the meantime I found out, what's happening. I have to note, that I have noticed and tested this issue only in XP. Every time, when no control has the focus in the dialog, ALT mode will be entered - and that is happening after ModifyStyle, DoModal. I inserted a SetFocus() after DoModal, and the problem is cleared. Then I tested around, and found, that in other cases, when no control is focused on (for example, when the currently focused control becomed disabled), ALT mode will be entered. The ALT status was easy to notice, because a PreTranslateMessage handler processes certain Alt-key combinations, like AltReturn, AltRight, etc., and these functions showed up without having touched the Alt key before. Thanks anyway.
Vancouver wrote: Every time, when no control has the focus in the dialog, ALT mode will be entered - and that is happening after ModifyStyle, DoModal. I think you will find that if no control has focus the Dialogs System Menu will get focus, which will then process keys as SystemKeys (ALT style). The first control with a Tab Stop style will automatically get focus so shouldn't normally need to use SetFocus(). Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
Vancouver wrote: Every time, when no control has the focus in the dialog, ALT mode will be entered - and that is happening after ModifyStyle, DoModal. I think you will find that if no control has focus the Dialogs System Menu will get focus, which will then process keys as SystemKeys (ALT style). The first control with a Tab Stop style will automatically get focus so shouldn't normally need to use SetFocus(). Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
1. I DID find, that PreTranslateMessage received the ALT key combinations in this situation (where the ALT has been simulated). Btw, this is a dialog-based application, there is no system menu. I realize I should have written that in the first post. 2. The first non-disabled tab-stop button DOES receive the focus automatically, but not always. One case is after the ModifyStyle + DoModal, another case was when the focus was on a CEdit control, which became disabled and the focus has not been assigned. As soon as the focus will be assigned explicitely when disabling the control, the problem is gone. Now I am assigning the focus to the dialog, i.e. with "this", which then gives the focus automatically to the first control in the TAB sequence.