Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to restrict the number of lines in a TMemo Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
111
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How can I get the following to happen with a memo: I would like to make it start 
purging lines from the top when a line is added at the bottom after I have 1024 
lines.

Answer:

You can do the following (I am making the example for TCustomMemo to make this more 
general).
1   
2   TLimitedMemo = class(TCustomMemo)
3   private
4     fChanging: Boolean;
5   protected
6     procedure Change; override;
7   public
8     constructor Create(AOwner: TComponent); override;
9   end;
10  
11  procedure TLimitedMemo.Change;
12  var
13    i: Integer;
14  begin
15    if fChanging then
16      Exit;
17    inherited;
18    with Lines do
19    try
20      BeginUpdate;
21      if Count > 5 then
22      begin
23        fChanging := True;
24        for i := 0 to Count - 6 do
25          Delete(0);
26        fChanging := False;
27      end;
28    finally
29      EndUpdate;
30    end;
31  end;
32  
33  constructor TLimitedMemo.Create(AOwner: TComponent);
34  begin
35    inherited Create(AOwner);
36    fChanging := False;
37  end;


In this case, this memo is allowing 5 lines(you can change it at your will).

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC