Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollng via keyboard keys

Status
Not open for further replies.

philrock

Programmer
Jan 29, 2004
109
US
How do you get forms to scroll in response to the keyboard Up, Down, Page Up, and Page Down keys?
 
interesting question.... intrigued me just enough to go look.

I just went through an exercise of making all my windows "automatically resize" components etc when formresize called.....

The only answer I see is:

select your menu, press F11 to get the object inspector, click on vertscrollbar and do ctrl+F1 and read it... it's going to take some work but...

That's one of the reasons I did the automatic resizing of components so I wouldn't have to train people "how to..."

HTH,
JGS
 
I try this, and it works for my Quick Report Preview that I made customized by myself..


procedure TQRCustomPreview.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_UP: SendMessage(QRPreview.Handle, WM_VSCROLL, 0, 0);
VK_DOWN: SendMessage(QRPreview.Handle, WM_VSCROLL, 1, 0);
VK_LEFT: SendMessage(QRPreview.Handle, WM_HSCROLL, 0, 0);
VK_RIGHT: SendMessage(QRPreview.Handle, WM_HSCROLL, 1, 0);
end;
end;

QRPreview.Handle can be replace with Self.Handle for the form itself, or any descendant of TWinControl handle property..
 
I agree, Indrahig's solution will work just fine.... however, in his solution one is causing ALL of windows to "workout twice" (once to trap the keystroke, 2ndly to send the message) just because one key was pressed....

I feel that a simple increment of the position property is much less taxing on the system as a whole...

And, I applaud his diligence...

JGS
 
Wondering if it works if the focus is not in the form itself but in some control inside the form... what probably is not an issue for a report, anyway.

buho (A).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top