Search code examples
delphirichedit

Scrolling RichEdit without it having focus


I need to scroll a RichEdit to the very end after a line is added. I have this RichEdit in a separate form, that I don't want to get focus at all. I tried often suggested solution:

RichEdit.Lines.Add(someText);
RichEdit.SelStart:=RichEdit.GetTextLen;
SendMessage(RichEdit.handle, EM_SCROLLCARET, 0, 0);

But this doesn't work for me. However, when I focus the RichEdit before calling the SendMessage using RichEdit.SetFocus; it works just fine. That, however, ruins my other needs for the app.

I'm using XE2. Thanks


Solution

  • This is what I do:

    SendMessage(RichEdit.Handle, WM_VSCROLL, SB_BOTTOM, 0);