• Scrollbox的滚动条事件scrollbar事件的处理(Lazarus)


    没办法,改源代码:

    找到:Forms单元中scrollbox的父类:
    TScrollingWinControl = class(TCustomControl) 
     
    改:
    { TScrollingWinControl }
      //
      //begin
      TOnAfterScroll=procedure(ScrollKind: TScrollBarKind; OldPosition: Integer) of object;
      //end
      //  
     
     
    TScrollingWinControl = class(TCustomControl)
      private
        FHorzScrollBar: TControlScrollBar;
        FVertScrollBar: TControlScrollBar;
        FAutoScroll: Boolean;
        FIsUpdating: Boolean;
        FonAfterScroll:TOnAfterScroll;//*********add by aliyagoo.com
        procedure SetHorzScrollBar(Value: TControlScrollBar);
        procedure SetVertScrollBar(Value: TControlScrollBar);
        function StoreScrollBars: Boolean;
      protected
        class procedure WSRegisterClass; override;
        procedure AlignControls(AControl: TControl; var ARect: TRect); override;
        procedure CreateWnd; override;
        function GetClientScrollOffset: TPoint; override;
        function GetLogicalClientRect: TRect; override;// logical size of client area
        procedure DoOnResize; override;
        procedure WMHScroll(var Message : TLMHScroll); message LM_HScroll;
        procedure WMVScroll(var Message : TLMVScroll); message LM_VScroll;
        function ComputeScrollbars: Boolean; virtual;
        procedure ScrollbarHandler(ScrollKind: TScrollBarKind;
                                   OldPosition: Integer); virtual;
        procedure SetAutoScroll(Value: Boolean); virtual;
        procedure Loaded; override;
        property AutoScroll: Boolean read FAutoScroll write SetAutoScroll default False;
      public
        constructor Create(TheOwner : TComponent); override;
        destructor Destroy; override;
        procedure UpdateScrollbars;
        function HasVisibleScrollbars: boolean; virtual;
        class function GetControlClassDefaultSize: TPoint; override;
        procedure ScrollBy(DeltaX, DeltaY: Integer);
        property OnAfterScroll:TOnAfterScroll read FonAfterScroll write FonAfterScroll;//***********add by aliyagoo.com
      published
        property HorzScrollBar: TControlScrollBar
                  read FHorzScrollBar write SetHorzScrollBar stored StoreScrollBars;
        property VertScrollBar: TControlScrollBar
                  read FVertScrollBar write SetVertScrollBar stored StoreScrollBars;
      end;               
    然后在Scrollbox里公开属性【公开,不是发布】。
     
    插入事件:ScrollingWinControl.inc 文件
     
    procedure TScrollingWinControl.ScrollbarHandler(ScrollKind: TScrollBarKind;
      OldPosition: Integer);
    begin
      if ScrollKind = sbVertical then
        ScrollBy(0, FVertScrollBar.Position - OldPosition)
      else
        ScrollBy(FHorzScrollBar.Position - OldPosition, 0);
     
        //***********add by aliyagoo
        if Assigned(OnAfterScroll) then FOnAfterScroll(ScrollKind,OldPosition);
        //***********end add
    end;                      

    http://blog.sina.com.cn/s/blog_56294d0a0100w4lx.html

  • 相关阅读:
    autorun.inf删除方法
    Re_Write序列号
    最常用的正则表达式
    SQL聚合使用GROUP BY
    Ext.Net的Window控件的简单使用
    SQL统计查询一个表中的记录,然后减法运算
    C#金额转换为汉字大写
    Ext.Net的Button按钮的使用
    C# 参考之方法参数关键字:params、ref及out 引用
    C#连接ACCESS 2007数据库
  • 原文地址:https://www.cnblogs.com/findumars/p/4759182.html
Copyright © 2020-2023  润新知