RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TScrollBar.LargeChange Property

Determines how much Position changes when the user clicks the scroll bar on either side of the thumb tab or presses PgUp or PgDn.

Pascal
property LargeChange: TScrollBarInc;
C++
__property TScrollBarInc LargeChange;

Set LargeChange to specify how much to change the value of Position when the user clicks on the side of the thumb tab (that is, on the thumb tab track, but not on the thumb tab itself). The Max and Min properties define the total range over which Position can vary. 

For example, if Max is 30000 and Min is 0, the scroll box can assume 30,000 positions. If the LargeChange property setting is 10000 and the Position property is 0, the user can click the scroll bar track three times after the thumb tab before it moves all the way to the end of the scroll bar (30000 / 10000 = 3). 

LargeChange should correspond to the portion of this range that the user sees in one page or screen, expressed in the logical units used by the Max, Min, and Position properties.  

C++ Examples: 

 

/*
This example shows how to use a scroll bar to navigate the
pages of a page control.  To run this example, place a
scroll bar and a page control on a form.  Right click the
page control and add 12 pages to it.  Add the following code
to the OnCreate event of the form, the OnChange event of the
page control, and the OnScroll event of the scroll bar.
Note that the LargeChange and SmallChange properties are set
to automatically change the active page by one tab or one
row respectively.  The OnScroll event is used to make the
actual change in the page control, while the OnChange event
of the page control ensures that the scroll bar is kept in
sync with changes made directly to the page control.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  const TColor colorPalette[12] = {clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia, clTeal, clNavy, clMaroon, clLime, clOlive, clPurple};
  // First, initialize the page control
  PageControl1->TabWidth = PageControl1->ClientWidth/4 - 1;
  PageControl1->ActivePage = PageControl1->Pages[0];
  for (int i = 0; i < PageControl1->PageCount; i++)
    PageControl1->Pages[i]->Brush->Color = colorPalette[i];
  /* set up the scrollbar to reflect
     the structure of the page control */
  ScrollBar1->Max = PageControl1->PageCount - 1;
  ScrollBar1->Min = 0;
  ScrollBar1->SmallChange = 1;
  // set LargeChange to a single row of tabs 
  ScrollBar1->LargeChange = PageControl1->ClientWidth / PageControl1->TabWidth;
}

void __fastcall TForm1::PageControl1Change(TObject *Sender)
{
  ScrollBar1->Position = ((TPageControl *)Sender)->ActivePage->PageIndex;
}

void __fastcall TForm1::ScrollBar1Scroll(TObject *Sender,
      TScrollCode ScrollCode, int &ScrollPos)
{
  PageControl1->ActivePage = PageControl1->Pages[ScrollPos];
}

 

Delphi Examples: 

{
This example shows how to use a scroll bar to navigate the
pages of a page control.  To run this example, place a
scroll bar and a page control on a form.  Right click the
page control and add 12 pages to it.  Add the following code
to the OnCreate event of the form, the OnChange event of the
page control, and the OnScroll event of the scroll bar.
Note that the LargeChange and SmallChange properties are set
to automatically change the active page by one tab or one
row respectively.  The OnScroll event is used to make the
actual change in the page control, while the OnChange event
of the page control ensures that the scroll bar is kept in
sync with changes made directly to the page control.
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  i : Integer;
const
  colorpalette: Array[0..11] of TColor = (clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia, clTeal, clNavy, clMaroon, clLime, clOlive, clPurple);
begin
  { First, initialize the page control }
  PageControl1.TabWidth := PageControl1.ClientWidth div 4 - 1;
  PageControl1.ActivePage := PageControl1.Pages[0];
  for i := 0 to PageControl1.PageCount - 1 do
    PageControl1.Pages[i].Brush.Color:= colorPalette[i];
  { set up the scrollbar to reflect the structure of the page control}
  with ScrollBar1 do
  begin
    Max := PageControl1.PageCount - 1;
    Min := 0;
    SmallChange := 1;
    { set LargeChange to a single row of tabs }
    LargeChange := PageControl1.ClientWidth div PageControl1.TabWidth;
  end;
end;

procedure TForm1.PageControl1Change(Sender: TObject);
begin
  with Sender as TPageControl do
    ScrollBar1.Position := ActivePage.PageIndex;
end;

procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
  var ScrollPos: Integer);
begin
  PageControl1.ActivePage := PageControl1.Pages[ScrollPos];
end;

 

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