Solved

TMemo - How to add lines of text without scrolling

Posted on 2004-09-06
3
1,094 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now