Ja gut, dann musst du wirklich in der innersten Komponente im Event ein Event feuern und das nach oben leiten bis zu TBar und dann zum User.
Finde ich aber besser als irgendwo irgendwelche Koordinaten abzufragen oder sowas..
Delphi-Quellcode:
TFoo = class(TCustomControl)
private
FSomeVar: TSomeType;
protected
procedure WM_Paint(var Msg: TMessage) message WM_PAINT;
public
property OnGetSubComponents;
property OnButtonClick: TNotifyEvent read FOnButtonClick write FOnButtonClick;
end;
procedure TFoo.Button1Click(Sender: TObject);
begin
if Assigned(FOnButtonClick) then
FOnButtonClick(Sender);
end;
// TFooBar
TFooBar = class(TCustomControl)
private
FSomeVar: TFoo;
protected
procedure WM_Paint(var Msg: TMessage) message WM_PAINT;
property OnButtonClick: TNotifyEvent read FOnButtonClick write FOnButtonClick;
end;
constructor TFooBar.Create()
begin
FSomeVar.OnButtonClick := InternalButtonClick;
end;
procedure TFooBar.InternalButtonClick()
begin
if Assigned(FOnButtonClick) then
FOnButtonClick(Sender);
end;
// TBar
TBar = class(TCustomControl)
private
FSomeVar: TFooBar;
protected
procedure WM_Paint(var Msg: TMessage) message WM_PAINT;
public
property OnGetSomeData;
end;
constructor TBar.Create()
begin
FSomeVar.OnButtonClick := InternalButtonClick;
end;
procedure TBar.InternalButtonClick()
begin
if Assigned(FOnButtonClick) then
FOnButtonClick(Sender);
end;
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."