初识类的事件

http://www.cnblogs.com/del/archive/2008/01/11/1034525.html

 

  TMyEvent =  procedure of object;

  {TMyClass 类} TMyClass = class
  strict private
    FAge: Integer;           {年龄字段}
    FOnHundred: TMyEvent;    {为我们刚刚定义的 TMyEvent 类型指定一个变量: FOnHundred}
    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; {其实事件也是属性}
    {事件命名一般用 On 开始}
  end;

posted on 2010-08-27 15:57  dengdeng  阅读(97)  评论(0编辑  收藏  举报

导航