TScrollBox 是不少控件(TMemo、TListBox、TStringGrid、TTreeView、TImageViewer 等)的基础, 所以先学.
TVertScrollBox 只比 TScrollBox 少了竖滚动条.
TFramedScrollBox、TFramedVertScrollBox 只是套用了不同的样式, 有可视的框架.
{ TScrollBox } public constructor Create(...); override; // destructor Destroy; override; // procedure AddObject(...); override; // procedure Sort(...); override; //根据指定的排序函数给内部对象排序 procedure MouseDown(...); override; // procedure MouseMove(...); override; // procedure MouseUp(...); override; // procedure MouseWheel(...); override; // procedure Realign; override; // procedure Centre; //滚动到中间位置 procedure ScrollTo(...); //滚动指定的距离 procedure InViewRect(...); //暂未实现 function ClientWidth: Single; //客户区宽度 function ClientHeight: Single; //客户区高度 property HScrollBar: TScrollBar ...; //横滚动条对象 property VScrollBar: TScrollBar ...; //竖滚动条对象 published property AutoHide: Boolean ...; //是否根据需要自动隐藏或显示滚动条; 默认 True property Animated: Boolean ...; //是否使用滚动动画; 默认 True property DisableMouseWheel: Boolean ...; //是否禁用鼠标滚动轮; 默认 False, 未禁用 property MouseTracking: Boolean ...; //能否用鼠标直接拖动(拖到控件, 滚动条联动); 默认 False property ShowScrollBars: Boolean ...; //是否显示滚动条; 默认 True property ShowSizeGrip: Boolean ...; //是否显示 Grip(右下角的拖拽标识); 默认 False property UseSmallScrollBars: Boolean ...; //是否使用小的滚动条 end;
示例:
uses FMX.Layouts, FMX.Objects; var ScrollBox1: TScrollBox; Rectangle1: TRectangle; procedure TForm1.FormCreate(Sender: TObject); begin ScrollBox1 := TScrollBox.Create(Self); ScrollBox1.Parent := Self; ScrollBox1.Align := TAlignLayout.alClient; ScrollBox1.MouseTracking := True; Rectangle1 := TRectangle.Create(Self); Rectangle1.Parent := ScrollBox1; Rectangle1.SetBounds(100, 100, ClientWidth*2, ClientHeight*2); end;