首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

这个Delphi控件鼠标捕捉如何用的

2012-06-24 
这个Delphi控件鼠标捕捉怎么用的?在网上抄的代码,不知道在Delphi中如何操作,才能输入以下代码?好像是鼠标

这个Delphi控件鼠标捕捉怎么用的?
在网上抄的代码,不知道在Delphi中如何操作,才能输入以下代码?好像是鼠标滚动代码,我不知道如何操作,才能让下面代码起作用?

Delphi(Pascal) code
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;


[解决办法]
Delphi(Pascal) code
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. 

热点排行