在网上抄的代码,不知道在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;
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;
解决方案 »
- 如何列出超始两个IP地址之间的所有合法IP地址?
- dbcombobox选择当前值
- application.terminate后报错?指教?
- Delphi如何用DataSet接收存储过程中返回多个数据集中的某个数据集
- 给群群的分,算你狠~~~
- 请教如何将delphi中的数据传送到word表格的指定单元格中,很急!!
- 把包含一个类的unit写成dll,应该怎么写?
- 窗口控制问题:按下一个TForm对象的'最小','最大','X(关闭)',分别对应那个响应函数,如何使这些操作不产生效果?
- 如何在程序中将焦点移到某一控件,谢谢
- delphi上运行可以,外面(还是本机)就不行了? 99我!!
- cxgrid中,如何根据列名或字段名取得footer值
- 如图所示,软件界面是什么控件做的,有谁可以做
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := ApplicationEvents1Message;
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.
你试试
关于 TApplicationEvents.OnMessage 的
var Handled: Boolean);
var
Rotation: ShortInt;
begin
if (Msg.message = WM_MOUSEWHEEL) and
(Msg.hwnd = self.Handle) then //只对当前窗口的鼠标滚动消息进行处理
begin
Rotation := HIWORD( Msg.wParam );
if Rotation > 0 then
Inc( Num )
else
Dec( Num );
SetLabelCaption( Num );
Handled := True;
end;
end;
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);是不是放错地方了,或者是要加什么单元?