PageSize (Delphi)
Description
The following code sets the thumb tab of a scroll bar so that it represents the proportion of the scrolling range that is visible.
Code
procedure SetThumbTab(wincontrol: TWinControl);
var
TrackHeight: Integer; { The size of the scroll bar track }
MinHeight: Integer; { The default size of the thumb tab }
begin
MinHeight := GetSystemMetrics(SM_CYVTHUMB); { Save the default size. }
with Form1.ScrollBar1 do
begin
TrackHeight := wincontrol.ClientHeight - 2 * GetSystemMetrics(SM_CYVSCROLL);
PageSize := TrackHeight div (Max - Min + 1);
if PageSize < MinHeight then PageSize := MinHeight;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
const
Path = 'OverView.RTF';
begin
RichEdit1.PlainText := False;
RichEdit1.Lines.LoadFromFile(Path);
SetThumbTab(RichEdit1);
end;
procedure TForm1.RichEdit1Change(Sender: TObject);
begin
SetThumbTab(RichEdit1);
end;
Uses
- Vcl.StdCtrls.TScrollBar.PageSize ( fr | de | ja )