截获WM_HSCROLL和WM_VSCROLL消息即可吗
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
FClientInstance,
FPrevClientProc : TFarProc;
procedure ClientWndProc(var Message: TMessage);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ClientWndProc(var Message: TMessage);
begin
with Message do
case Msg of
WM_HSCROLL:
begin
// CustomProcedureWhenHScroll()
ShowMessage('WM HSCROLL Message') ;
Result := 1;
end;
WM_VSCROLL:
begin
// CustomProcedureWhenVScroll()
ShowMessage('WM VSCROLL Message') ;
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(TreeView1.Handle, GWL_WNDPROC));
SetWindowLong(TreeView1.Handle, GWL_WNDPROC, LongInt(FClientInstance));
end;
end.
看看有没有用