unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure abuttonmousedown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var a:tbutton;
procedure TForm1.abuttonmousedown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
begin
showmessage('自定义事件');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=tbutton.Create(self);
a.parent:=form1;
a.show;
a.caption:='自建按钮';
a.OnMouseDown :=abuttonmousedown;
end;
end.