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. Setting focus to a control

Setting focus to a control

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 6 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.
  • C Offline
    C Offline
    cowell
    wrote on last edited by
    #1

    In a dialog, i have some buttons and a CEdit control. How would I set the focus to the edit control? tanx

    P R 2 Replies Last reply
    0
    • C cowell

      In a dialog, i have some buttons and a CEdit control. How would I set the focus to the edit control? tanx

      P Offline
      P Offline
      Pete 2
      wrote on last edited by
      #2

      Use SetFocus

      C 1 Reply Last reply
      0
      • P Pete 2

        Use SetFocus

        C Offline
        C Offline
        cowell
        wrote on last edited by
        #3

        okay, whoops, i should have said that i have a CString mapped to the control. I suppose I have to map a CEdit as well to be able to focus it...

        M M 2 Replies Last reply
        0
        • C cowell

          okay, whoops, i should have said that i have a CString mapped to the control. I suppose I have to map a CEdit as well to be able to focus it...

          M Offline
          M Offline
          Member 1033907
          wrote on last edited by
          #4

          What does it mean 'to have a CString mapped to the control' ??? If you'll be more specific maybe I'll help you Honza

          C 1 Reply Last reply
          0
          • C cowell

            okay, whoops, i should have said that i have a CString mapped to the control. I suppose I have to map a CEdit as well to be able to focus it...

            M Offline
            M Offline
            Mike Dunn
            wrote on last edited by
            #5

            Two ways: 1. GotoDlgCtrl ( GetDlgItem ( IDC_MY_EDITBOX )); 2. GetDlgItem ( IDC_MY_EDITBOX )->SetFocus();

            1 Reply Last reply
            0
            • M Member 1033907

              What does it mean 'to have a CString mapped to the control' ??? If you'll be more specific maybe I'll help you Honza

              C Offline
              C Offline
              cowell
              wrote on last edited by
              #6

              i meant that in Class Wizard member variables i put a CString onto the edit box. I put a CEdit onto the edit box as well, so i can use SetFocus like that. I was just wondering if you could do it without having to have a CEdit just for that. if u get what i mean :).

              X 1 Reply Last reply
              0
              • C cowell

                i meant that in Class Wizard member variables i put a CString onto the edit box. I put a CEdit onto the edit box as well, so i can use SetFocus like that. I was just wondering if you could do it without having to have a CEdit just for that. if u get what i mean :).

                X Offline
                X Offline
                xtsea
                wrote on last edited by
                #7

                CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->SetFocus ();

                1 Reply Last reply
                0
                • C cowell

                  In a dialog, i have some buttons and a CEdit control. How would I set the focus to the edit control? tanx

                  R Offline
                  R Offline
                  realJSOP
                  wrote on last edited by
                  #8

                  Use this: GotoDlgCtrl(GetDlgItem(IDC_MYCONTROL)); That way, you don't need to setup a member variable of the control type...

                  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