没办法,改源代码:
找到: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