Setting the cursor position in CEdit control.
-
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.
-
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.
You can use the EM_SETSEL message (CEdit::SetSel()) to position the caret in the control. MArk
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
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.
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
-
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
-
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