Link to home
Start Free TrialLog in
Avatar of Hanqian
Hanqian

asked on

How to control cursor and backspac's position in edit control?

I have an edit control, how I set the cursor to the position that I want within this control, for example, after I type two characters, I don't want the cursor stay at third position instead I want the cursor jump to the fouth position. The same thing for "back space" key, if there is a text in control, and I used this key to delete from the end of text, but I don't want to delete a special character in this text, how to let "back space" jump over from this character to next character.

Thanks.
Hanqian
 
SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hanqian
Hanqian

ASKER

I have tried it, it doesn't work. After I type two chars. I use pEdit->SetSel(4, 4), it doesn't go to the position 4.

Hanqian
Avatar of AndyAinscow
I assume your control is empty when you start typing.
You would need to add the third (space) character yourself then position at the end (4th) position.
Avatar of Hanqian

ASKER

I did add "/" at third position.

Hanqian
If edit control has 3 characters, you can write:

pEdit->SetSel(3, 3);

4 is still out of range.
Avatar of Hanqian

ASKER

That means that we can't use SetSel() to set the cursor at the blank position of the edit control.

Hanqian
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial