community.borland.com

Article #15593: How to scroll your form with pgUP and pgDn.

 Technical Information Database

TI593D.txt   How to scroll your form with pgUP and pgDn.
Category   :VCL
Platform    :All
Product    :Delphi  All

Description:
Q.   How can you do scrolling functions in a TForm component 
using  keyboard commands?  For example, scrolling up and down 
when a  PgUp or PgDown is pressed.  Is there some simple way to 
do this or does it have to be programmed by capturing the 
keystrokes and manually responding to them?

A.    Form scrolling is accomplished by modifying the 
VertScrollbar  or HorzScrollbar Postion properties of the 
form.  The following code demonstrates how to do this:

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;

Reference:


7/16/98 4:33:48 PM
 

Last Modified: 01-SEP-99