• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Scrolling TRichEdit

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

  RichEdit.Lines.Add('Blah');

??
0
nrico
Asked:
nrico
1 Solution
 
RBertoraCommented:
Richedit.Setfocus;

then each time you add, use:

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

Rob;-)
0
 
nricoAuthor Commented:
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?
0
 
RBertoraCommented:
No you wouldn't have to change focus all the time. infact you don't have to use setfocus at all.

Rob;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
edeyCommented:
or you could try this :)


EM_SCROLLCARET

wParam = 0 ;    // not used now; reserved for future use; must be zero
lParam = 0 ;    // not used now; reserved for future use;  must be zero
 

An application sends an EM_SCROLLCARET message to scroll the caret into view in an edit control.




GL
Mike
0
 
kretzschmarCommented:
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
0
 
edeyCommented:
Thank you, glad to be of service :)


GL
Mike
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now