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. SetFocus??

SetFocus??

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • M Offline
    M Offline
    MemLeak
    wrote on last edited by
    #1

    Hi, I have a Dialogbar with some edit control into it. I want to set the focus on the first one. The focus seem to work right because the caret appear in the first edit control but my text in the control is not selected. what am I doing wrong? I would like to have the text selected so that I could change my text into the control without having to delete it first. thanks for helping Mykel Everything's beautiful if you look at it long enough...

    V J M 3 Replies Last reply
    0
    • M MemLeak

      Hi, I have a Dialogbar with some edit control into it. I want to set the focus on the first one. The focus seem to work right because the caret appear in the first edit control but my text in the control is not selected. what am I doing wrong? I would like to have the text selected so that I could change my text into the control without having to delete it first. thanks for helping Mykel Everything's beautiful if you look at it long enough...

      V Offline
      V Offline
      vcplusplus
      wrote on last edited by
      #2

      Use SetSel(..) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/\_mfc\_cedit.3a3a.setsel.asp

      1 Reply Last reply
      0
      • M MemLeak

        Hi, I have a Dialogbar with some edit control into it. I want to set the focus on the first one. The focus seem to work right because the caret appear in the first edit control but my text in the control is not selected. what am I doing wrong? I would like to have the text selected so that I could change my text into the control without having to delete it first. thanks for helping Mykel Everything's beautiful if you look at it long enough...

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        Are you calling MyEdit.SetSel(0, -1); ? This should select the whole text content of your edit box. [EDIT]This is the same as calling

        ::SendMessage(
        (HWND) hWnd, // handle to destination window
        EM_SETSEL, // message to send
        (WPARAM) 0, // starting position
        (LPARAM) -1 // ending position
        );

        [/EDIT]


        Who is 'General Failure'? And why is he reading my harddisk?!?

        1 Reply Last reply
        0
        • M MemLeak

          Hi, I have a Dialogbar with some edit control into it. I want to set the focus on the first one. The focus seem to work right because the caret appear in the first edit control but my text in the control is not selected. what am I doing wrong? I would like to have the text selected so that I could change my text into the control without having to delete it first. thanks for helping Mykel Everything's beautiful if you look at it long enough...

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          I have the same kind of problem ... when my editbox received the focus, I want to select all text in it.

          ON_EN_SETFOCUS(CMbCoordEdit::IDC_EDIT2, OnSetfocusControl2)
          ...

          void CMbCoordCtrl::OnSetfocusControl2()
          {
          m_edit2.SetSel( 0, -1);
          }

          That doesn't work when clicking in the editbox. Setting the selection manually from another function works, but not like that. any hints ? Thanks.


          Maximilien Lincourt "Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )

          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