[lazarus] How to scroll TMemo control in code

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Mar 29 12:18:23 EST 2003

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. 


More information about the Lazarus mailing list