[lazarus] How to scroll TMemo control in code

Marc Weustink marc.weustink at cuperus.nl
Mon Mar 31 04:49:26 EST 2003

+ From: Mattias Gaertner [mailto:nc-gaertnma at netcologne.de]
+ On Mon, 31 Mar 2003 07:54:11 +0800
+ hernan.et at pg.com wrote:

+ > By the way, I managed to move the scrollbar in code last week end but I
+ > noticed that as the contents of memo gets larger and larger, appending
+ > text becomes slower. Part of the reason maybe because my code
+ > will scroll the TMemo to bottom everytime I add the text. But looking
+ > at how TMemo inserts text, it is deleting the entire contents and
replace it
+ > with a new one (gtkObject.inc). It tried figuring out how the content is
+ > updated but to no avail, I just dont really get it. Can somebody
+ > please help me understand how the updated text is send to gtk
+ Very slow.
+ To accelerate this, you can improve the TMemoStrings functions to send
+ messages directly to the interface. Invent new messages LM_InsertText and
+ LM_DeleteText. The reading is also very slow. The Text should be
+ stored and only fetched from the inteface, when it has changed.
+ Then you need also a callback.

I also noticed this. Another reason IMO for being slow is that TStrings.Text
is used several times. On each call the text has to be reassembled from all
its lines. A while ago I planned to create a TStrings descendant which is
text based and not linebased (or has TMemoStrings already that functionality
?). IMO you gain more speed with this than changing some interface calls
(altough that will improve it also)


More information about the Lazarus mailing list