Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ALT key state after ModifyStyle, DoModal

ALT key state after ModifyStyle, DoModal

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vancouver
    wrote on last edited by
    #1

    I have a problem with the combination of ModifyStyle and DoModal: 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 with EndDialog, 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 a SetKeyboardState, clearing the ALT status (testwise clearing the status of ALL keys too). This works so far, that a subsequent GetKeyboardState showsn that the ALT key is not toggled any more. However, when any key gets pressed now, PreTranslateMessage shows WM_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?

    N 1 Reply Last reply
    0
    • V Vancouver

      I have a problem with the combination of ModifyStyle and DoModal: 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 with EndDialog, 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 a SetKeyboardState, clearing the ALT status (testwise clearing the status of ALL keys too). This works so far, that a subsequent GetKeyboardState showsn that the ALT key is not toggled any more. However, when any key gets pressed now, PreTranslateMessage shows WM_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?

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      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"

      V 1 Reply Last reply
      0
      • N Neville Franks

        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"

        V Offline
        V Offline
        Vancouver
        wrote on last edited by
        #3

        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.

        N 1 Reply Last reply
        0
        • V Vancouver

          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.

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #4

          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"

          V 1 Reply Last reply
          0
          • N Neville Franks

            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"

            V Offline
            V Offline
            Vancouver
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups