TmyEvent = procedure of object;
TmyClass = class
private
Fage: Integer;
FonHundred: TmyEvent;
procedure SetAge(const Value: Integer);
public
procedure SetOnHundred1;
procedure SetOnhundred2;
constructor Create;
property Age: Integer read Fage write SetAge;
property OnHundred: TmyEvent read FonHundred write FonHundred;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TMyClass.Create;
begin
FonHundred := SetOnHundred1;
end;
procedure TmyClass.SetAge(const value: Integer);
begin
if (Value > 0) and (Value < 200) then
Fage := Value;
if Value = 100 then
OnHundred;
end;
procedure TmyClass.SetOnhundred2;
begin
ShowMessage('100啦!');
end;
procedure TmyClass.SetOnHundred1;
begin
ShowMessage('刚好100啦');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
TmyCls: TmyClass;
begin
TmyCls
初探类的字段.属性.方法.事件
最新推荐文章于 2017-07-17 14:31:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)