Hi,

You can just scroll the TMemo to the last line after you done with the addition 
and removal. Something like this:

>     Memo.Lines.Add(buf);
>     if Memo.Lines.Count > 22 then
>         Memo.lines.Delete(0);
      Memo.ScrollBy(0, Memo.Lines.Count);


Luthfi

--- On Fri, 12/14/12, John Dammeyer <[email protected]> wrote:

> From: John Dammeyer <[email protected]>
> Subject: RE: What is the best way to add objects to TMemo.Lines
> To: "'Moderated List for the Discussion of Delphi Programming 
> excludingDatabase-related topics'" <[email protected]>
> Date: Friday, December 14, 2012, 5:03 PM
> Hi Everyone,
> 
> That does add an interesting question.
> 
> How to create a screen similar to hyperterm or any serial
> terminal where
> the text is added to the end and the earliest line of the
> screen is lost.
> 
>     Memo.Lines.Add(buf);
>     if Memo.Lines.Count > 22 then
>         Memo.lines.Delete(0);
> 
> As long as the screen is longer than 22 lines the added line
> is always
> visible.  But if the buffer size was to be say 128 so
> that last 128 lines
> are accessible then the new line is added to the end but the
> Delete(0) in
> addition to removing the oldest line also repositions the
> list starting at
> the first.
> 
> Having to move a scroll down bar after each entry is
> tedious.  Especially
> if they are lines from a serial port.
> 
> Another option is to just remove half the Tmemo buffer.
> 
>     if COMTraffic.Lines.Count > 200 then begin
>         bufsize :=
> COMTraffic.GetTextlen;
>         bufsize := bufsize div 2;
>         COMTraffic.Selstart := 0;
>         COMTraffic.SelLength :=
> bufsize;
>         COMTraffic.SelText;
>         COMTraffic.ClearSelection;
>     end;
> 
> 
> Other suggestions?
> 
> John
> 
> "ELS! The Solution"
> Automation Artisans Inc.
> http://www.autoartisans.com/ELS/
> Ph. 1 250 544 4950
_______________________________________________
Delphi mailing list
[email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to