Following is a minimal example of using an interposer class to add a new method
to a TPanel.
type
TPanel = class(ExtCtrls.TPanel)
protected
procedure Update(Param : String);
end;
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
public
end;
[...]
{ TPanel }
procedure TPanel.Update(Param: String);
begin
Caption := 'ParamValue: ' + Param;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel1.Update('abc');
end;
Note that you have to add the method to a class descended from ExtCtrls.TPanel.
You cannot add a method to an instance of TPanel, because that's not the way Delphi
works, Delphi generates code for the class's methods, not for a specific instance of the class.
Note also that there is nothing to stop you giving the interposer class the same name
as the class it descends from (the unit qualifier "ExtCtrls" disambiguates the two).
Note also that the interposer class can be in a separate unit from your form; in that
case the interposer class units has to appear in your form's Uses
list after ExtCtrls.