请问在用DELPHI创建DLL文件的时候,要想动态创建一个TTimer控件,并写事件OnTimer,该如何做?library MyDll;uses
Dialogs,ExtCtrls;Var MyTimer:TTimer;procedure MyTimerOnTimer(Sender:TObject);
begin
ShowMessage('aa');
end;begin
MyTimer:=TTimer.Create(nil);
MyTimer.OnTimer := MyTimerOnTimer; // 编译不过.
// Incompatible types: 'method pointer and regular procedure'
end;
end.请问是什么错误?
Dialogs,ExtCtrls;Var MyTimer:TTimer;procedure MyTimerOnTimer(Sender:TObject);
begin
ShowMessage('aa');
end;begin
MyTimer:=TTimer.Create(nil);
MyTimer.OnTimer := MyTimerOnTimer; // 编译不过.
// Incompatible types: 'method pointer and regular procedure'
end;
end.请问是什么错误?
解决方案 »
- 开始上班散发啦..........................
- 有没有人用过 CBX 开发BS架构的程序?
- 如何更改一个字段成主键字段啊,SQL语句怎么样写?
- 关于OutLook的帐号和密码问题求助
- 我 要delphi 7 的打包工具那里有啊(大哥们)
- 简单的问题?有谁能告诉我,好吗?
- 关于delphi存储过程控件使用碰到的一个问题,在线等待!!!
- 我用clientdataset1.GetNextPacket下载资料时,如何让我知道全部的数据包已下载完毕,并结束getnextpacket,请高手指点。
- 狂狼,你在哦,呵呵。。。。。。
- 运程数据模块问题
- ProgressBar的用法
- 怎样使用ActiveX的.lic文件?
============================
library MyDll;uses
Dialogs,ExtCtrls;Var MyTimer:TTimer;procedure MyTimerTimer(Sender:TObject);
begin
ShowMessage('aa');
end;begin
MyTimer:=TTimer.Create(nil);
MyTimer.OnTimer := MyTimerTimer; // 编译不过.
// Incompatible types: 'method pointer and regular procedure'
end;
end.
Timer的OnTimer()事件的原形你要搞清楚!
=======================================
procedure TForm1.Timer1Timer(Sender: TObject);
begin
... ...
end;
能举例吗? 谢谢.> to : lgqTiger(把酒论程序__尽在笑谈间)
你说要改的代码和我上面的一样啊? 不是吗?
Forms,Dialogs,ExtCtrls;
type
TForm1 = class(TForm)
private
procedure MyTimerOnTimer(Sender:TObject);
{ Private declarations }
public
{ Public declarations }
end;var MyTimer:TTimer;procedure TForm1.MyTimerOnTimer(Sender:TObject);
begin
ShowMessage('aa');
end;begin
MyTimer:=TTimer.Create(nil);
MyTimer.OnTimer:=MyTimerOnTimer; //Undeclared identifier:'MyTimerOnTimer'
//一样编译不过啊,如果是在Form里面,在FomrCreate事
//件中写这两句代码就能运行,但在DLL里为什么不可以?
end.这个问题应该不难吧,新年论坛人少吗?
现在一些DLL木马是不是也是在DLL里自定义TCPServer或是TCPClient,然后写它们的相关代码的??
library MyDll;uses
Dialogs,ExtCtrls;
type
Tmyclass = class
private
procedure MyTimerOnTimer(Sender:TObject);
public
end;var MyTimer:TTimer;
myclass:TMyClass;procedure Tmyclass.MyTimerOnTimer(Sender:TObject);
begin
ShowMessage('aa');
end;begin
MyTimer:=TTimer.Create(nil);
MyClass:=TMyClass.Create;
MyTimer.OnTimer:=myclass.MyTimerOnTimer;
end.
Dialogs,ExtCtrls;Var MyTimer:TTimer;procedure MyTimerOnTimer(Sender:TObject);
begin
ShowMessage('aa');
end;begin
MyTimer:=TTimer.Create(nil);
MyTimer.OnTimer := @MyTimerOnTimer; // 前面加一个@
end;
end.