如何捕获treeView的滚动条滚动事件 ( 积分: 30 )

  • 主题发起人 主题发起人 songjy
  • 开始时间 开始时间
S

songjy

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,谢谢
 
如题,谢谢
 
截获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.

看看有没有用
 
谢谢,太感谢了
 
后退
顶部