I have an object inheriting from TPanel declared in a seperate unit:
type
TPreviewPanel = class(TPanel)
private
procedure ImagePreviewClick(Sender: TObject);
protected
{ Protected Declarations }
public
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
published
{ Published Declarations }
end;
Then in the main unit I try to create it:
procedure TForm1.Insert1Click(Sender: TObject);
var temp: TPreviewPanel;
begin
temp:= TPreviewPanel.Create(self);
temp.Parent:= self; //<--- error here
end;
But I get a compilation error saying that TWidgetControl and TForm1 are incompatible types. If I transfer the class definition to the main unit it works correctly. Please can anyone tell me how I keep these in seperate units, without the error? I have included the seperate unit in my uses.
type
TPreviewPanel = class(TPanel)
private
procedure ImagePreviewClick(Sender: TObject);
protected
{ Protected Declarations }
public
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
published
{ Published Declarations }
end;
Then in the main unit I try to create it:
procedure TForm1.Insert1Click(Sender: TObject);
var temp: TPreviewPanel;
begin
temp:= TPreviewPanel.Create(self);
temp.Parent:= self; //<--- error here
end;
But I get a compilation error saying that TWidgetControl and TForm1 are incompatible types. If I transfer the class definition to the main unit it works correctly. Please can anyone tell me how I keep these in seperate units, without the error? I have included the seperate unit in my uses.