K
kingmax
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
//tcountbutton=class (tbutton)
procedure FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
tcountbutton=class (tbutton)
constructor create (aowner:tcomponent);override;
destructor destroy
override;
class function gettotal:integer;
end;
constructor tcountbutton.create(aowner: TComponent);
begin
inherited Create(aowner);
inc (totbtns);
end;
destructor tcountbutton.destroy;
begin
dec(totbtns);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
totbtns:integer=0;
class function tcountbutton.gettotal: integer;
begin
result:=totbtns;
end;
procedure TForm1.FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
with tcountbutton.create (self) do
begin
parent:=self;
left:=x;
top:=y;
width:=width+50;
caption:=format('button at %d,%d',[x,y]);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
caption:=format('countobj:%d custom buttons',[tcountbutton.gettotal]);
end;
end.
说明:窗体中只有一个timer,和它的ontimer事件。
请大侠告诉我这个错误究竟是怎么回事?怎样改正。
不胜感激!
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
//tcountbutton=class (tbutton)
procedure FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
tcountbutton=class (tbutton)
constructor create (aowner:tcomponent);override;
destructor destroy
override;
class function gettotal:integer;
end;
constructor tcountbutton.create(aowner: TComponent);
begin
inherited Create(aowner);
inc (totbtns);
end;
destructor tcountbutton.destroy;
begin
dec(totbtns);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
totbtns:integer=0;
class function tcountbutton.gettotal: integer;
begin
result:=totbtns;
end;
procedure TForm1.FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
with tcountbutton.create (self) do
begin
parent:=self;
left:=x;
top:=y;
width:=width+50;
caption:=format('button at %d,%d',[x,y]);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
caption:=format('countobj:%d custom buttons',[tcountbutton.gettotal]);
end;
end.
说明:窗体中只有一个timer,和它的ontimer事件。
请大侠告诉我这个错误究竟是怎么回事?怎样改正。
不胜感激!