type
TButtonPanel = class(TCustomPanel)//随手写,不知道应该是什么类,下同
private
FButton: TButton;
FButtonClickEvent: TNotifyEvent;
//作为中转,应该是这么写吧
procedure OnBtnClick(Sender: TObject);
protected
public
constructor Create(Owner: TComponent);override;
destructor Destroy;override;
published
property OnButtonClick read FButtonClickEvent write FButtonClickEvent;
end;
implementation
constructor Create(Owner: TComponent);
begin
//创建,可能不对,但是就是这个意思
FButton := TButton.Create(Self);
with FButton do
begin
Parent := Self;
OnClick := OnBtnClick;
end;
end;
destructor Destroy;
begin
inherited;
end;
procedure OnBtnClick(Sender: TObject);
begin
//做你在用户的Click之前的动作
//
//执行用户的Click事件
if assigned(OnButtonClick) then OnButtonClick(Self);
//
//做你在用户的Click之后的动作
end;