RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TControlScrollBar.Increment Property

Determines how far the display moves when the user clicks one of the small end arrows on the scroll bar.

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

Use Increment to control how the scroll bar affects the scrollable region of the control. If Increment is set to 1, each click scrolls by one position; if Increment is set to 2, each click scrolls by two positions; and so forth.

Note: Do not use the Increment property when Smooth is set to true. When Smooth is true, every time the range or visibility of the scroll bar changes, the value of Increment is dynamically recomputed.
 

C++ Examples: 

 

/*
This example starts the form in a position scrolled so that
the right hand edge shows:
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  /* set the width of the form window to display 300 pixels in the client area */
  ClientWidth = 300;
  /* now set the range to twice the client width.
   This means that the form has a logical size
   that is twice as big as the physical window.
   Note that Range must always be at least as big as ClientWidth! */
  HorzScrollBar->Range = 600;
  /* start the form fully scrolled */
  HorzScrollBar->Position = HorzScrollBar->Range - ClientWidth;
  /* clicking the scroll arrows moves the form 10 pixels */
  HorzScrollBar->Increment = 10;
  HorzScrollBar->Visible = true;  // Show the scrollbar
}
/*
The following example demonstrates form scrolling with the
PgUp and PgDn keys.
*/
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
  const int iPageDelta = 10;

  if (Key == VK_NEXT)
    VertScrollBar->Position += iPageDelta;
  else if (Key == VK_PRIOR)
    VertScrollBar->Position -= iPageDelta;
}

 

Delphi Examples: 

{
This example starts the form in a position scrolled so that
the right hand edge shows:
}
procedure TForm1.FormCreate(Sender: TObject);
begin
  ClientWidth := 300;
  with HorzScrollBar do
  begin
    { Set the range to twice the ClientWidth of the form }
    { This means that the form’s logical size is twice as big }
    { as the physical window. }
    { Note that Range must always be larger than the ClientWidth }
    Range := 600; 
    Position := Range - ClientWidth; { start form out fully scrolled }
    Increment := 10;  { clicking the scroll arrows moves the form 10 pixels }
    Visible := True;  { Show the scrollbar }
  end;
end; 

 

{
The following example demonstrates form scrolling with the
PgUp and PgDn keys.
}
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
const
  PageDelta = 10;
begin
  With VertScrollbar do
    if Key = VK_NEXT then
      Position := Position + PageDelta
    else if Key = VK_PRIOR then
      Position := Position - PageDelta;
end;

 

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