Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

TMemo - How to add lines of text without scrolling

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

837 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