Link to home
Start Free TrialLog in
Avatar of toanphan
toanphan

asked on

How to position the caret in CEdit

When I select the entire text in an edit box by calling CEdit::SetSel, the caret is automatically moved to the end of the selection.  However, I want to be able to keep the caret at the beginning of the text when it's highlighted, not at the end of it.  So the question is, is there a way to move the caret to position 0 in a CEdit when the text highlighted?
Toan Phan
Avatar of ddeboskey
ddeboskey

A call to SetCaretPos should be able to move the caret after the call to SetSel.  Since SetCaretPos takes an X and Y coordinate, you may need to call CEdit::PosFromChar() in order to obtain the correct coordinates for the right character index.  

I hope this helps.
Dave.
Avatar of toanphan

ASKER

The caret is a shared resource, and a call to SetCaretPos for CEdit does not have any effect.  Any examples how to do this would really help.
Thanks.
The caret is a shared resource, and a call to SetCaretPos for CEdit does not have any effect.  Any examples how to do this would really help.
Thanks.
Use CEdit::SetSel(...)
Sorry, didnt read the question fully. The answer is not there isnt.
Bridge did not give the answer as he misread the question.  Any other answers?
ASKER CERTIFIED SOLUTION
Avatar of wyy_cq
wyy_cq

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