给组件添加自己的事件

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   procedure TForm1.add_notify(Sender: TObject);  //声明
   procedure FormCreate(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.add_notify(Sender: TObject);
begin
showmessage('ddddd');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
button1.onClick:=add_notify;   //赋事件,不需要添加参数
end;

end.

posted @ 2004-09-11 11:32  泡面 @ 幸福  阅读(432)  评论(0编辑  收藏  举报