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. Edit control focus locks application

Edit control focus locks application

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

    :confused:Hi, I have a simple dialog box that has an edit control. I want the dialog box to come up with the cursor in the edit box ready for input. I can do this using myDialog::UpdateDialogControls(pWndCtrl, TRUE) but then the focus is locked on the edit control and I can't use the OK or CANCEL buttons and I have to use the task manager to end the application. I have also tried the GotoCtrl(pWndCtrl) with UpdateData() and UpdateWindow() and some other variations that seemed like they might work but they have no effect at all. This is probably very simple, I just can't seem to figure out the right command sequence. Buck

    B D K 4 Replies Last reply
    0
    • B BuckBrown

      :confused:Hi, I have a simple dialog box that has an edit control. I want the dialog box to come up with the cursor in the edit box ready for input. I can do this using myDialog::UpdateDialogControls(pWndCtrl, TRUE) but then the focus is locked on the edit control and I can't use the OK or CANCEL buttons and I have to use the task manager to end the application. I have also tried the GotoCtrl(pWndCtrl) with UpdateData() and UpdateWindow() and some other variations that seemed like they might work but they have no effect at all. This is probably very simple, I just can't seem to figure out the right command sequence. Buck

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      BuckBrown wrote:

      I want the dialog box to come up with the cursor in the edit box ready for input.

      The first control on the dialog that has an id other than IDC_STATIC will automatically get the initial focus. Otherwise, you'll need to call SetFocus(). If you opt for this, be sure and return FALSE from OnInitDialog().


      "Take only what you need and leave the land as you found it." - Native American Proverb

      1 Reply Last reply
      0
      • B BuckBrown

        :confused:Hi, I have a simple dialog box that has an edit control. I want the dialog box to come up with the cursor in the edit box ready for input. I can do this using myDialog::UpdateDialogControls(pWndCtrl, TRUE) but then the focus is locked on the edit control and I can't use the OK or CANCEL buttons and I have to use the task manager to end the application. I have also tried the GotoCtrl(pWndCtrl) with UpdateData() and UpdateWindow() and some other variations that seemed like they might work but they have no effect at all. This is probably very simple, I just can't seem to figure out the right command sequence. Buck

        B Offline
        B Offline
        bugDanny
        wrote on last edited by
        #3

        There should be a SetFocus() function you can use. Danny The stupidity of others amazes me!

        1 Reply Last reply
        0
        • B BuckBrown

          :confused:Hi, I have a simple dialog box that has an edit control. I want the dialog box to come up with the cursor in the edit box ready for input. I can do this using myDialog::UpdateDialogControls(pWndCtrl, TRUE) but then the focus is locked on the edit control and I can't use the OK or CANCEL buttons and I have to use the task manager to end the application. I have also tried the GotoCtrl(pWndCtrl) with UpdateData() and UpdateWindow() and some other variations that seemed like they might work but they have no effect at all. This is probably very simple, I just can't seem to figure out the right command sequence. Buck

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

          Sorry, or SET SEL. Danny The stupidity of others amazes me!

          B 1 Reply Last reply
          0
          • B BuckBrown

            :confused:Hi, I have a simple dialog box that has an edit control. I want the dialog box to come up with the cursor in the edit box ready for input. I can do this using myDialog::UpdateDialogControls(pWndCtrl, TRUE) but then the focus is locked on the edit control and I can't use the OK or CANCEL buttons and I have to use the task manager to end the application. I have also tried the GotoCtrl(pWndCtrl) with UpdateData() and UpdateWindow() and some other variations that seemed like they might work but they have no effect at all. This is probably very simple, I just can't seem to figure out the right command sequence. Buck

            K Offline
            K Offline
            kakan
            wrote on last edited by
            #5

            Set the edit control to be the first item in the tab order (Crtl-D in VC6)

            1 Reply Last reply
            0
            • B bugDanny

              Sorry, or SET SEL. Danny The stupidity of others amazes me!

              B Offline
              B Offline
              BuckBrown
              wrote on last edited by
              #6

              Thanks, Although it would seem that GotodlgCtrl(pEditCtrl) followed by SetFocus() should do the trick it doesn't. It needs to be in the syntax of GotoDlgCtrl(pEditCtrl->SetFocus());

              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