[lazarus] How to scroll TMemo control in code

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon Mar 31 04:27:52 EST 2003




On Mon, 31 Mar 2003, Mattias Gaertner wrote:

> On Mon, 31 Mar 2003 07:54:11 +0800
> hernan.et at pg.com wrote:
>
> > Does this mean that I will use TMemoScrollBar or is TMemo a descendant of
> > TMemoScrollBar?
>
> TMemo has now two new properties:
>
>     property HorzScrollBar: TMemoScrollBar;
>     property VertScrollBar: TMemoScrollBar;
>
>
> > I will try to check out latest cvs today and give it a try.
> >
> > 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 interface????
>
> For example:
>
> TMemo.Lines.Add('new line');
> calls
> TStrings.Add
> calls
> TMemoStrings.Insert
> sets
> FMemo.Text
> calls
> TCustomEdit.SetText
> calls
> TControl.SetText
> calls
> TControl.SetTextBuf
> calls
> CNSendMessage(LM_SetLabel, ...
> calls
> SendMsgToInterface(
> calls
> TInterfaceBase.IntSendMessage3
> which is abstract and so it calls
> TgtkObject.IntSendMessage3
> calls
> TgtkObject.SetLabel
>
> 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.

You should add BeginUpdate and EndUpdate to speed up loading of a memo,
as well. Delphi has it and it is recommended to put a
BeginUpdate/EndUpdate pair around code that changes the list in a memo
often.

Michael.






More information about the Lazarus mailing list