unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TMyControl = class(TCustomPanel)
public
property OnClick;
end;
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
procedure MyControlOnClick(Sender: TObject);
public
{ Public declarations }
MyControl: TMyControl;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
MyControl := TMyControl.Create(Self);
MyControl.Parent := Self;
MyControl.Align := alClient;
MyControl.Show;
MyControl.OnClick := MyControlOnClick;
MyControl.Caption := 'sadasdasd';
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FreeAndNil(MyControl);
end;
procedure TForm1.MyControlOnClick(Sender: TObject);
begin
ShowMessage('ok');
end;
end.