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)
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;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
totbtns:integer=0;
class function tcountbutton.gettotal: integer;
begin
result:=totbtns;
end;
constructor tcountbutton.create(aowner: TComponent);
begin
inherited Create(aowner);
inc (totbtns);
end;
destructor tcountbutton.destroy;
begin
dec(totbtns);
end;
procedure TForm1.FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
var
btn:tcountbutton;
begin
btn:=tcountbutton.create (self);
btn.parent:=self;
btn.Left:=x;
btn.Top:=y;
btn.Width:=btn.Width+50;
btn.caption:=format('button at %d,%d',[x,y]);
{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.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
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;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
totbtns:integer=0;
class function tcountbutton.gettotal: integer;
begin
result:=totbtns;
end;
constructor tcountbutton.create(aowner: TComponent);
begin
inherited Create(aowner);
inc (totbtns);
end;
destructor tcountbutton.destroy;
begin
dec(totbtns);
end;
procedure TForm1.FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
var
btn:tcountbutton;
begin
btn:=tcountbutton.create (self);
btn.parent:=self;
btn.Left:=x;
btn.Top:=y;
btn.Width:=btn.Width+50;
btn.caption:=format('button at %d,%d',[x,y]);
{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.