[lazarus] How to scroll TMemo control in code

hernan.et at pg.com hernan.et at pg.com
Wed Apr 2 17:26:33 EST 2003


Mattias,

Please give me more details and I will try to implement it.

Yoyong


                                                                
 Internet Mail Message                                          
 Received from host:                                            
 svcr-216-37-230-2.dsl.svcr.epix.net                            
 [216.37.230.2]                                                 
                                                                


From: Mattias Gaertner <nc-gaertnma at netcologne.de> on 03/31/2003 09:37 AM GMT
                                                                                  
            Mattias Gaertner           To:   lazarus at miraclec.com                 
 <nc-gaertnma at netcologne.de>           Cc:    (bcc: Yoyong Hernan-ET/PGI)         
                               Subject:      Re: [lazarus] How to scroll TMemo    
                                    control in code                               
         03/31/2003 05:37 PM                                                      
           Please respond to                                                      
        lazarus at miraclec.com                                                      
                                                                                  





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.

If you want to do that, just ask and I will give you more deatails.


Mattias


>
> snip....
>
> ......
>      myMemo : TMemo;
>
> ......
>
> procedure TfrmTest.Button1Click(Sender : TObject);
> var
>      i : Integer;
> begin
>      for i := 0 to 1000 do
>      begin
>           myMemo.Lines.Add("Hello Lazarus");
>      end;
> end;
>
> snip.....
>
> If I understand it right, we must just append "Hello Lazarus" to the
> current text that is inside GtkText object. But as I said, looking at
> gtkobject.inc, we delete the whole text and then insert. Which I believe
> is the cause of slow down in appending many short text in TMemo.
>
> Again, to make my self clear, can somebody help me understand how the
> lines property of TMemo gets send to gtkObject.inc??????
>
> Regards,
>
> Yoyong
>
>
>
>  Internet Mail Message
>  Received from host:
>  svcr-216-37-230-2.dsl.svcr.epix.net
>  [216.37.230.2]
>
>
>
> From: Mattias Gaertner <nc-gaertnma at netcologne.de> on 03/29/2003 05:34 PM
> GMT
>

>             Mattias Gaertner           To:   lazarus at miraclec.com
>
>  <nc-gaertnma at netcologne.de>           Cc:    (bcc: Yoyong Hernan-ET/PGI)
>
>                                Subject:      Re: [lazarus] How to scroll
>                                TMemo
>                                     control in code
>
>          03/30/2003 01:34 AM
>
>            Please respond to
>
>         lazarus at miraclec.com
>
>

>
>
>
>
>
> On Sat, 29 Mar 2003 12:15:19 +0100
> Marc Weustink <marc at dommelstein.net> wrote:
>
> > At 10:45 29-3-2003 +0100, you wrote:
> > >On 28 Mar 2003 11:07:59 -0500
> > >andrew johnson <acjgenius at earthlink.net> wrote:
> > >
> > > > I think this is a great idea. And FYI.. the only reasons
> > > > TControlScrollBar is so inflexible is because, a) I didn't know what
> > > > I was doing. and b) because I was only attempting to implement what
> > > > was needed for TScrollingWinControl stuff. So, if it is possible to
> > > > make as many of these changes as possible directly in
> > > > TControlScrollBar without breaking TScrollingWinControl, and Delphi
> > > > compatibility in that regard I think it would make more sense to do
> > > > so.
> > >
> > >Yep.
> > >I changed the FControl in TControlScrollbar into a TWincontrol. Most of
> > >code only works if the FControl is a TScollingWinControl. For all other
> > >it does nothing.
> > >
> > >Now it's time for implementation.
> > >The TMemoScrollBar should be mostly readonly, but the position
> > >property. The TControlScrollbar is currently quite the opposite. It
> > >updates the position due to messages and set all other values (min,
> > >max, page) and even calculates the visibility itself.
> > >Therefore TControlScrollbar should for non-TScrollWinControls only read
> > >the values from the interface and raise an exception on writing the
> > >properties. TMemoScrollbar should implement SetPosition.
> > >TMemo must create/destroy the two TMemoScrollbar.
> > >
> > >So, we need functions to read
> > >Increment, Page, Min, Max, Range, Size, Position, Smooth
> > >and a function to set the
> > >Position
> >
> > I don't see any harm in setting Increment, Page and Smooth as well (half
> > page scrolling in stead of pagescrolling or so)
> >
> > >I think, we can simple use GetScrollInfo and SetScrollInfo.
> > >
> > >Ok?
> >
> > Think so.
>
> I changed TControlScrollBar, added TMemoScrollBar and added two public
> scrollbar properties to TCustomMemo. You can read Visible, Position,
> Range, Page and Size and write Position and Page.
> Only one new interface function was neccessary: GetScrollBarVisible, which
> was missing in GetScrollInfo.
> Increment and Smooth are also missing and are left as an exercise.
>
>
> Mattias
>
> _________________________________________________________________
>      To unsubscribe: mail lazarus-request at miraclec.com with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives
>
>
> _________________________________________________________________
>      To unsubscribe: mail lazarus-request at miraclec.com with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________________
     To unsubscribe: mail lazarus-request at miraclec.com with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives







More information about the Lazarus mailing list