没有啊,我的是delphi6的环境。下面是全部代码,没出错啊。。。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ontimer(Sender: TObject);
procedure button2click(Sender: TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
time:ttimer;
abc:Tbutton;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
time :=Ttimer.create(nil);
time.interval :=1000;
time.ontimer :=ontimer;
time.enabled :=true;
abc:=Tbutton.Create(Self);
abc.Parent:=Form1;
abc.caption:='abc';
abc.Left :=20;
abc.Top :=20;
abc.onClick:=Button2Click;
end;
procedure Tform1.ontimer(Sender: TObject);
begin
showmessage('222');
end;
procedure Tform1.button2click(Sender: TObject);
begin
time.free;
Form1.Close;
end;
end.