Reading back through previous threads seems to indicate
that you somehow use CEdit's SetSel(). Can anyone tell me
what parameters to pass ? I want the cursor to be at the right
of any text and with no text highlighted.
If I have just used CEdit's SetWindowText() and then
called SetSel(1000,1000) (1000 being much greater
than text length) then this appears to work.
However the CEdit resides on a property page used as
a wizard, and I'm finding it impossible to control the CEdit
when people arrive on the page from another page's 'back'
or 'next' button. I can get the cursor to the end of the text
but the blasted text is still highlighted :-(
Before I completely loose the plot and try sending virtual
right key presses to the control, can anyone suggest how
to do it properly ?
TTFN,
Jon
So, something like:
CEdit txtText;
CString strText = "This is a test.";
txtText.SetWindowText(strText);
txtText.SetCurSel(strText.GetLength(),0);
BRM
Set the selection in the OnSetActive handler. You also need to set the focus first.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
"Joseph M. Newcomer" wrote:
> If the selection start and end are the same, you see no selection, you just get the caret.
>
> Set the selection in the OnSetActive handler. You also need to set the focus first.
> joe
>
Thanks Joe,
This is where the problem lies. I'm intercepting OnSetActive()
and that is when I cant seem to position the cursor withough
highlights.
Elsewhere I have buttons that used to append text to the
control (date and time for example) and the finish with :-
m_wndEditName.SetWindowText( csNew ) ;
m_wndEditName.SetFocus() ;
m_wndEditName.SetSel( csNew.GetLength(), csNew.GetLength() ) ;
This works !
However, in OnSetActive() :-
int nChars = m_wndEditName.GetLength() ;
m_wndEditName.SetSel( nChars, nChars )
positions the cursor at the end of the line but
also highlights part of the text.
TTFN,
Jon