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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Catch Form Scroll Event?

Status
Not open for further replies.

jbpelletier

Programmer
Sep 8, 2001
232
CA
Hi,

I have a TForm which has the autoscroll property set to true.

My problem is simple. I'm trying to catch the "on scroll" event of the form, but i can't find a way yet.

I'm using delphi 7. Any help appreciate.

Jb
 
I found a way. However, im not sure if it's the "elegant" way. So if you find a better solution, please tell me.

Here is what i did :

1- in my Tform class i've added the WMVScroll and WMHScroll Message Handler. Ex :

TForm1 = class(TForm)
...
private
{ Private declarations }
procedure WMVScroll(var Msg :TMessage); message WM_VSCROLL;
procedure WMHScroll(var Msg :TMessage); message WM_HSCROLL;

2- In my code i've add these 2 proc
procedure Tform1.WMVScroll(var Msg : TMessage);
begin
inherited;
{do something}
end;
//------------------------
procedure Tform1.WMHScroll(var Msg : TMessage);
begin
inherited;
{do something}
end;


jb
 
I haven't tested this, but to get you started on your way, dig down into the VCL to the TScrollingWinControl declaration. You'll notice that there are two message methods for vertical and horizontal scrolling.
Code:
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;

I'd start by adding those two message methods to your form as private methods, do whatever handling you want in them, and be sure to call inherited after or before you're done.
 
Thanks Griffyn, at least i know im on the good "track";)
jb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top