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. CDialog and tab key

CDialog and tab key

Scheduled Pinned Locked Moved C / C++ / MFC
c++cssquestion
9 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    Brian van der Beek
    wrote on last edited by
    #1

    I have a dialog with some buttons and MFC GridCtrl's. When the focus is on the last cell of the grid and the tab key is pressed, I want to set the focus to the next control. How do you do this? I have played around with the GetDlgCode() etc. but haven't really been able to get this working.

    B 3 Replies Last reply
    0
    • B Brian van der Beek

      I have a dialog with some buttons and MFC GridCtrl's. When the focus is on the last cell of the grid and the tab key is pressed, I want to set the focus to the next control. How do you do this? I have played around with the GetDlgCode() etc. but haven't really been able to get this working.

      B Offline
      B Offline
      BaldwinMartin
      wrote on last edited by
      #2

      Have you tried SetFocus() ???? Best Wishes, ez_way

      B 1 Reply Last reply
      0
      • B BaldwinMartin

        Have you tried SetFocus() ???? Best Wishes, ez_way

        B Offline
        B Offline
        Brian van der Beek
        wrote on last edited by
        #3

        I think I haven't explained myself correctly. What I need to know is where to catch the tab key and set the focus to the next control. Normally (e.g. with buttons etc.) the dialog seems to handle this.

        B 1 Reply Last reply
        0
        • B Brian van der Beek

          I think I haven't explained myself correctly. What I need to know is where to catch the tab key and set the focus to the next control. Normally (e.g. with buttons etc.) the dialog seems to handle this.

          B Offline
          B Offline
          BaldwinMartin
          wrote on last edited by
          #4

          Hi Brian Please don't yell for a stupid idea but the tab order you set with CTRL+D shows the tabs,... yes? Well with that in mind can you not set focus whereever you wish? I know this is really not a great answer but it worked for me in a tabbed prj. Best Wishes, ez_way

          B 1 Reply Last reply
          0
          • B Brian van der Beek

            I have a dialog with some buttons and MFC GridCtrl's. When the focus is on the last cell of the grid and the tab key is pressed, I want to set the focus to the next control. How do you do this? I have played around with the GetDlgCode() etc. but haven't really been able to get this working.

            B Offline
            B Offline
            BaldwinMartin
            wrote on last edited by
            #5

            Oh yes, one more thing when you set the focus please make sure to note the overload function. SetFocus(GetDlgItem(hDial, ID_VERT_RES)); Best Wishes, ez_way

            1 Reply Last reply
            0
            • B BaldwinMartin

              Hi Brian Please don't yell for a stupid idea but the tab order you set with CTRL+D shows the tabs,... yes? Well with that in mind can you not set focus whereever you wish? I know this is really not a great answer but it worked for me in a tabbed prj. Best Wishes, ez_way

              B Offline
              B Offline
              Brian van der Beek
              wrote on last edited by
              #6

              Martin, thanks for your reply, but that will not work for me as my controls are dynamically created.

              1 Reply Last reply
              0
              • B Brian van der Beek

                I have a dialog with some buttons and MFC GridCtrl's. When the focus is on the last cell of the grid and the tab key is pressed, I want to set the focus to the next control. How do you do this? I have played around with the GetDlgCode() etc. but haven't really been able to get this working.

                B Offline
                B Offline
                BaldwinMartin
                wrote on last edited by
                #7

                Yes sure but what about using TRY/CATCH to do the validation? Best Wishes, ez_way

                B 1 Reply Last reply
                0
                • B BaldwinMartin

                  Yes sure but what about using TRY/CATCH to do the validation? Best Wishes, ez_way

                  B Offline
                  B Offline
                  Brian van der Beek
                  wrote on last edited by
                  #8

                  :confused:

                  B 1 Reply Last reply
                  0
                  • B Brian van der Beek

                    :confused:

                    B Offline
                    B Offline
                    BaldwinMartin
                    wrote on last edited by
                    #9

                    Validating control contents when switching focus from one control to the next is done by handling the EN_KILLFOCUS notification sent by the edit control that is losing focus. You could trap TRY/CATCH this and send it along the way in a altered state! Best Wishes, ez_way

                    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