Perhaps it’s just monday morning making me confused, but let’s say I have this scenario:
<code>TMyControl = class(TWinControl);
TMyButton = class(TButton);
constructor TMyButton.Create(foo: TMyControl);
begin
inherited Create(foo);
end;
</code>
<code>TMyControl = class(TWinControl);
TMyButton = class(TButton);
constructor TMyButton.Create(foo: TMyControl);
begin
inherited Create(foo);
end;
</code>
TMyControl = class(TWinControl);
TMyButton = class(TButton);
constructor TMyButton.Create(foo: TMyControl);
begin
inherited Create(foo);
end;
I need a way to make TMyButton
both a subclass of TMyControl
and be a TButton
.
Is there any way to do that in Delphi?
For example something like (obviously just wishful thinking pseudocode):
<code>constructor TMyButton.Create(foo: TMyControl);
begin
Self := TButton.Create(foo);
end;
</code>
<code>constructor TMyButton.Create(foo: TMyControl);
begin
Self := TButton.Create(foo);
end;
</code>
constructor TMyButton.Create(foo: TMyControl);
begin
Self := TButton.Create(foo);
end;
If not, what other options do I have? The only thing I can think of is to make TMyControl
subclass TPanel
and make all its descendants (for example TMyButton
) wrap their actual controls (for example a TButton
) in a TPanel
… seems pretty ugly though.