Here's my constructors and destructors:
As stated earlier, your
TVersion constructor is not calling the inherited
TForm1 constructor, so none of the UI controls on your
TDownloadChannel Form are being created from the LFM. Always call inherited constructors!
Also, you cannot overload a destructor, you must override it instead.
Try this:
type
{ TForm1 }
TForm1 = class(TForm)
Download_Btn: TButton;
Info_Lbl: TLabel;
procedure Download_BtnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
public
end;
{TVersion}
TVersion = class(TForm1)
private
...
public
constructor Create(AOwner: TComponent; P: shortstring; Ns: shortstring); reintroduce;
destructor Destroy; override;
...
end;
{TDownloadChannel}
TDownloadChannel = class(TVersion)
private
...
public
constructor Create(AOwner: TComponent; P: shortstring); reintroduce; overload;
constructor Create(AOwner: TComponent; Cn: shortstring; Idx: Byte; Sv: Integer;
Fv: shortstring; Sl: shortstring; Fl: string; Cc: Char; P: shortstring; Ns: shortstring); overload;
destructor Destroy; override;
...
end;
constructor TVersion.Create(AOwner: TComponent; P: shortstring; Ns: shortstring);
begin
inherited Create(AOwner);
...
end;
destructor TVersion.Destroy;
begin
...
inherited Destroy;
end;
...
constructor TDownloadChannel.Create(AOwner: TComponent; P: shortstring);
begin
Create(AOwner, ' ', 0, 0, ' ', ' ', ' ', '#', P, ' ');
end;
constructor TDownloadChannel.Create(AOwner: TComponent; Cn: shortstring; Idx: Byte; Sv: Integer; Fv: shortstring;
Sl: shortstring; Fl: string; Cc: Char; P: shortstring; Ns: shortstring);
begin
inherited Create(AOwner, P, Ns);
...
end;
procedure TForm1.FormCreate(Sender: TObject);
var
...
begin
D1 := TDownloadChannel.Create(Self{or nil}, 'simple scheduler');
D1.WriteLabel;
...
end;
Now, that being said, I just noticed another problem -
TDownloadChannel derives from
TForm1, and
TForm1 has an
OnCreate event handler that creates a new instance of
TDownloadChannel. This means you have an endless recursion loop! Creating a new
TForm1 will create a new
TDownloadChannel, which will initialize its
TForm1 ancestor, which will create a new
TDownloadChannel, ... and so on, forever.
Your UI design is flawed. Either
TForm1 should not have an
OnCreate event handler that creates
TDownloadChannel, or
TDownloadChannel should not derive from
TForm1. I lean towards the latter - a download task should not itself
BE a UI, but it can update a
RELATED UI if needed. So, you should decouple your download logic from your UI logic. In this case, make
TVersion/
TDownloadChannel be a standalone class with no UI ancestor, and then give it a pointer to a separate
TForm1 object whose UI it should access.