RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TScrollBar.PageSize Property

Specifies the size of the thumb tab.

Pascal
property PageSize: Integer;
C++
__property int PageSize;

PageSize is the size of the thumb tab, measured in the same units as Position, Min, and Max (not pixels).  

C++ Examples: 

 

/*
The following code sets the thumb tab of a scroll bar so
that it represents the proportion of the scrolling range
that is visible:
*/
void __fastcall SetThumbTab()
{
  // Get the minimum (default) size of the thumb tab
  int MinHeight = GetSystemMetrics(SM_CYVTHUMB);
  // Get the size of the scrollbar track
  int TrackHeight = Form1->ScrollBar1->ClientHeight - 2*GetSystemMetrics(SM_CYVSCROLL);
  // set PageSize to represent the visible portion of the scrolling range:
  Form1->ScrollBar1->PageSize = TrackHeight/(Form1->ScrollBar1->Max - Form1->ScrollBar1->Min + 1);
  // Don’t let the thumb tab get too small
  if (Form1->ScrollBar1->PageSize < MinHeight)
  Form1->ScrollBar1->PageSize = MinHeight;
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  const AnsiString Path = "../overview.rtf";
  RichEdit1->PlainText = False;
  RichEdit1->Lines->LoadFromFile(Path);
  SetThumbTab();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RichEdit1Change(TObject *Sender)
{
 SetThumbTab();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
{
 SetThumbTab();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RichEdit1EndDrag(TObject *Sender, TObject *Target,
      int X, int Y)
{
 SetThumbTab();
}

 

Delphi Examples: 

{
The following code sets the thumb tab of a scroll bar so
that it represents the proportion of the scrolling range
that is visible:
} 
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 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;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!