Solved

TMemo - How to add lines of text without scrolling

Posted on 2004-09-06
3
1,102 Views
Last Modified: 2008-03-17
Using a TMemo component, and the .Lines.Add method to add text to the component, how do I keep the TMemo from scrolling downward as I add new text to the component?  In other words, if I use .Lines.Add 1000 times, the top line of the TMemo will be out of sight, and the last line will be visible in the TMemo.  I would prefer if the TMemo would cease scrolling while new lines are added.  Yes, I know how to rescroll the viewport/scrollbar back to the top, but this causes a flicker, and I'd much prefer to keep the TMemo frozen until all the new text has been added to it.

How can I perform this?

Thanks.
0
Comment
Question by:Monroe406
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Evarest
ID: 11991275
Maybe best to add these lines to a TStringList first and then copy its contents to your memo. This will be _a lot_ faster and you won't have any flickering to worry about...

procedure Add1000Lines;
var
 Q: integer;
 List: TStringList;
begin
 List :=TStringList.Create;
 for Q :=0 to 999 do
  begin
   List.Add(inttostr(Q));
  end;
 Memo1.Lines.AddStrings(List);
 List.Clear;
 List.Free;
end;

Of course, you'll need to alter this code to suite your needs...

Kind regards,
Evarest
0
 
LVL 4

Accepted Solution

by:
Evarest earned 50 total points
ID: 11991285
BTW, you can "freeze" the memo by calling BeginUpdate and EndUpdate:

procedure Add1000Lines;
var
 Q: integer;
begin
 Memo1.Lines.BeginUpdate;
 try
  for Q :=0 to 999 do
   begin
    Memo1.Lines.Add(inttostr(Q));
   end;
 finally
  Memo1.Lines.EndUpdate;
 end;
end;

Evarest

0
 

Author Comment

by:Monroe406
ID: 11991329
The BeginUpdate / EndUpdate methods are all I really need.  Adding these 2 lines before and after my .Lines.Add will meet my needs.  Thanks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wininet read php file from internet issue 6 91
Working with hours 3 58
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 67
Wincontrol not (correctly) drawn 15 38
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question