TonMsg = procedure(s: string) of object;

  Tman = class
  private
    fAge: integer;
    fonMsg: TonMsg;
    procedure setFage(iAge: integer);
  published
    property onMsg: TonMsg read fonMsg write fonMsg;
    property age: integer read fAge write setFage;
  public
    procedure Msg(s: string);
  end;

procedure Tman.setFage(iAge: integer);
begin
  if iAge > 0 then
  begin
    fAge := iAge;
    if iAge = 100 then
      ShowMessage('oh! happy you to 100year')
    else
      ShowMessageFmt('HI is %d', [iAge]);
  end
  else
    ShowMessageFmt('请输入无符号整数,您输入的"%D"不被支持', [iAge]);
end;

procedure Tman.Msg(s: string);
begin
  ShowMessage(s);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  TiMan: Tman;
  i:integer;
begin
if edt1.Text<>'' then
begin
  i:=StrToIntDef(edt1.Text,0);
  TiMan := Tman.Create;
  TiMan.onMsg := TiMan.Msg;
  //TiMan.onMsg('success');
  TiMan.age := i;
  TiMan.Free;
end;
end;