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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TO place SetCaretPos at The end of the text

TO place SetCaretPos at The end of the text

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

    Hello, I want to place the caret position at the end of the text in a CRichEditCtrl. But when it naturally moves to the CRichEditCtrl box the caret is placed at the beginning. I tried the message EM_POSFROMCHAR but it takes one character and gives its position and I cant give that last one character as it can repeat in between somewhere. How should I place the caret at the end? I hope my question was clear. Thanks for the codeproject forum. Pritha :)

    M 1 Reply Last reply
    0
    • P prithaa

      Hello, I want to place the caret position at the end of the text in a CRichEditCtrl. But when it naturally moves to the CRichEditCtrl box the caret is placed at the beginning. I tried the message EM_POSFROMCHAR but it takes one character and gives its position and I cant give that last one character as it can repeat in between somewhere. How should I place the caret at the end? I hope my question was clear. Thanks for the codeproject forum. Pritha :)

      M Offline
      M Offline
      msn92
      wrote on last edited by
      #2

      You cannot move the caret using SetCaretPos() for CEdit and CRichEditCtrl. INFO[^] To move the caret use SetSel and specify the same start pos and end pos. Example:

      ...
      int p=m_RichEditCtrl.GetWindowTextLength()-1;
      m_RichEditCtrl.SetSel(p,p);
      ...

      Hope that helps.

      P 1 Reply Last reply
      0
      • M msn92

        You cannot move the caret using SetCaretPos() for CEdit and CRichEditCtrl. INFO[^] To move the caret use SetSel and specify the same start pos and end pos. Example:

        ...
        int p=m_RichEditCtrl.GetWindowTextLength()-1;
        m_RichEditCtrl.SetSel(p,p);
        ...

        Hope that helps.

        P Offline
        P Offline
        prithaa
        wrote on last edited by
        #3

        Hey thanks it helped.

        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