这个Delphi控件鼠标捕捉怎么用的?
在网上抄的代码,不知道在Delphi中如何操作,才能输入以下代码?好像是鼠标滚动代码,我不知道如何操作,才能让下面代码起作用?
procedure TForm1.SetLabelCaption( ANum: Integer );begin Label1.Caption := IntToStr( ANum );end;procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);var Rotation: ShortInt;begin if Msg.message = WM_MOUSEWHEEL then begin Rotation := HIWORD( Msg.wParam ); if Rotation > 0 then Inc( Num ) else Dec( Num ); SetLabelCaption( Num ); Handled := True; end;end;
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, AppEvnts;type TForm1 = class(TForm) Label1: TLabel; ApplicationEvents1: TApplicationEvents; procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); private { Private declarations } procedure SetLabelCaption( ANum: Integer ); public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SetLabelCaption( ANum: Integer );begin Label1.Caption := IntToStr( ANum );end;procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);var Rotation: ShortInt; num:integer;begin if Msg.message = WM_MOUSEWHEEL then begin Rotation := HIWORD( Msg.wParam ); if Rotation > 0 then Inc(Num) else Dec( Num ); SetLabelCaption( Num ); Handled := True; end;end;end.