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. SetCursorPos and GetWindowText

SetCursorPos and GetWindowText

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++jsontutorial
2 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.
  • M Offline
    M Offline
    misha_grewal
    wrote on last edited by
    #1

    Hi, I am a newbie in MFC gui programming. Here is one problem that I am facing.. I am setting text in an edit control and then i need to set the cursor at the end of the text. If I use SetEditSel, it highlights the text also. I do not want the highlighting of the text. I just want the cursor to be at the end of the text ,after I have called SetWindowText(). I searched around and found that SetCursorPos can help. But I do not know how to provide the correct text coordinates to this API. any ideas would be greatly appreciated. Code snippet: InSomeHandler(){ GetWindowText(str); // do something SetWindowText(str); // set the cursor at the end: don't know how to do it.. } Be the change you wish to see...

    D 1 Reply Last reply
    0
    • M misha_grewal

      Hi, I am a newbie in MFC gui programming. Here is one problem that I am facing.. I am setting text in an edit control and then i need to set the cursor at the end of the text. If I use SetEditSel, it highlights the text also. I do not want the highlighting of the text. I just want the cursor to be at the end of the text ,after I have called SetWindowText(). I searched around and found that SetCursorPos can help. But I do not know how to provide the correct text coordinates to this API. any ideas would be greatly appreciated. Code snippet: InSomeHandler(){ GetWindowText(str); // do something SetWindowText(str); // set the cursor at the end: don't know how to do it.. } Be the change you wish to see...

      D Offline
      D Offline
      Dominik Reichl
      wrote on last edited by
      #2

      You can use SetSel for this. I assume you're using a CEdit control. Let's say this control is accessed through a member variable called m_edit and contains the text str, you can then set the cursor to the end of the control by calling this: m_edit.SetSel(str.GetLength(), 0, FALSE);


      Too many passwords to remember? Try KeePass Password Safe!

      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