Link to home
Start Free TrialLog in
Avatar of nrico
nrico

asked on

Scrolling TRichEdit

How can I make the TRichEdit scroll along with the text when I automatically add lines to it:

  RichEdit.Lines.Add('Blah');

??
Avatar of RBertora
RBertora
Flag of United Kingdom of Great Britain and Northern Ireland image

Richedit.Setfocus;

then each time you add, use:

SendMessage(RichEdit.Handle,WM_KeyDown,40,0);

Rob;-)
Avatar of nrico
nrico

ASKER

Wait, I forgot to tell the lines are added from a TEdit control, but I want the Edit to keep focus (It's for a chat program -- My friends wanted colors in it :-). So I'd have to keep switching focus, right?
No you wouldn't have to change focus all the time. infact you don't have to use setfocus at all.

Rob;-)
ASKER CERTIFIED SOLUTION
Avatar of edey
edey

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
hi,

another way (sample)

you can use this to scroll one line

//Scroll Up
procedure TForm1.Button1Click(Sender: TObject);
begin
  richedit1.Perform(EM_SCROLL,SB_LINEUP,0);
end;

//Scroll Down
procedure TForm1.Button2Click(Sender: TObject);
begin
  richedit1.Perform(EM_SCROLL,SB_LINEDOWN,0);
end;

meikl
Thank you, glad to be of service :)


GL
Mike