unit
CountBtn;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TCountBtn =
class
(TButton)
private
FCount:
integer
;
protected
procedure
Click;override;
procedure
MouseLeave; override;
public
procedure
ShowCount;
published
property
Count:
integer
read FCount
write
FCount;
constructor
Create(aowner:Tcomponent); override;
end
;
procedure
Register;
implementation
procedure
Register;
begin
RegisterComponents(
'Mihan Components'
, [TCountBtn]);
end
;
constructor
TCountBtn
.
Create(aowner:Tcomponent);
begin
inherited
create(Aowner);
end
;
procedure
TCountBtn
.
MouseLeave;
begin
inherited
mouseleave;
dec(fcount);
end
;
procedure
Tcountbtn
.
Click;
begin
inherited
click;
FCount:=FCount+
1
;
end
;
procedure
TCountBtn
.
ShowCount;
begin
Showmessage(
'По кнопке '
+ caption+
' вы сделали: '
+inttostr(FCount)+
' клик(а/ов)'
);
end
;
end
.