Board index » cppbuilder » How to place the cursor in TRichEdit

How to place the cursor in TRichEdit

Hello all:

I am trying to use a TRichEdit as a list of strings I add inside my app. The
way it works is like a chat program. I add every sentence in this way:

        MyRichEdit->Lines->Append(MyEdit->Text);

I have set ScrollBars property to ssBoth in order to let the user scroll
throughout the text but the problem is that as the program appends lines to the
component they disappear at the bottom of the window, forcing the user to
move the scrollbar.
I have tried to set SelStart property in this way:

        MyRichEdit->SelStart=(MyRichEdit->Lines->Text).Length();

but the problem is the same.
Is there any way to move the position of the RichEdit window so that the last
sentence is always seen by default?

Thank you very much and best regards

Rafael Caballos

 

Re:How to place the cursor in TRichEdit


You need to send a EM_SCROLLCARET message, ie:

    MyRichEdit->Lines->Append(MyEdit->Text);
    MyRichEdit->SelStart = MyRichEdit->GetTextLen();
    SendMessage(MyRichEdit->Handle, EM_SCROLCARET, 0, 0);

Gambit

Quote
"Rafael Caballos" <raf...@mail.com> wrote in message

news:3bb8da23_2@dnews...

Quote
> Is there any way to move the position of the RichEdit window so that the
last
> sentence is always seen by default?

Re:How to place the cursor in TRichEdit


Thank you again Remy. It works ok.

Rafael Caballos

Other Threads