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 the cursor position in CEdit control.

Setting the cursor position in CEdit control.

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestiondiscussion
5 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.
  • C Offline
    C Offline
    chandu004
    wrote on last edited by
    #1

    hai all, i will narrate an example, there by convey my doubt. in my edit box, the fifth character cannot be an alphabet. so if the user types 1a34 and D, i have to delete D from the string in the editchange event and replace the string 1a34 there, such that, the user can type a valid fifth character. here the problem iam getting is, if i do like this, the cursor is placed at the starting of the string. now is there any technique, suchthat, i can set the cursor at a required position? thanks for the opinions.

    M D 2 Replies Last reply
    0
    • C chandu004

      hai all, i will narrate an example, there by convey my doubt. in my edit box, the fifth character cannot be an alphabet. so if the user types 1a34 and D, i have to delete D from the string in the editchange event and replace the string 1a34 there, such that, the user can type a valid fifth character. here the problem iam getting is, if i do like this, the cursor is placed at the starting of the string. now is there any technique, suchthat, i can set the cursor at a required position? thanks for the opinions.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      You can use the EM_SETSEL message (CEdit::SetSel()) to position the caret in the control. MArk

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • C chandu004

        hai all, i will narrate an example, there by convey my doubt. in my edit box, the fifth character cannot be an alphabet. so if the user types 1a34 and D, i have to delete D from the string in the editchange event and replace the string 1a34 there, such that, the user can type a valid fifth character. here the problem iam getting is, if i do like this, the cursor is placed at the starting of the string. now is there any technique, suchthat, i can set the cursor at a required position? thanks for the opinions.

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

        chandu004 wrote:

        in my edit box, the fifth character cannot be an alphabet.

        It sounds like you need a masked edit control. See here and here.


        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        L C 2 Replies Last reply
        0
        • D David Crow

          chandu004 wrote:

          in my edit box, the fifth character cannot be an alphabet.

          It sounds like you need a masked edit control. See here and here.


          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          DavidCrow wrote:

          It sounds like you need a masked edit control

          Or maybe a Caped Crusader ;P

          1 Reply Last reply
          0
          • D David Crow

            chandu004 wrote:

            in my edit box, the fifth character cannot be an alphabet.

            It sounds like you need a masked edit control. See here and here.


            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            C Offline
            C Offline
            chandu004
            wrote on last edited by
            #5

            Thank you very very much for your reply. it seems that, this may be certainly useful for me. i shall do some exercise on that and come back to you.

            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