Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread TCell again
Tue, Jul 2 2013 5:08 AMPermanent Link

Ronald

Hi,

I create a component with the name TCell it is based upon a TPanel. Then I
created a component TMessage based on TCell. In the Create method of
TMessage I create a TPanel with the parent Self. If I free the component I
get an error (translated):

Can not get the property tfont_fname of an empty value...

I do not get the error if I set the parent of TPanel to AOwner (instead of
Self).

How can I solve this?


TCell = class(TPanel)
  private
  public
  constructor Create(AOwner: TComponent); override;
  end;

TPlane = class(TCell)
  private
  LPanel    :TPanel;
  public
  constructor Create(AOwner: TComponent); override;
  end;


implementation


//----------------------------------------------------------------------------------------------------
//TCell
//----------------------------------------------------------------------------------------------------
constructor TCell.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;


//----------------------------------------------------------------------------------------------------
//TPlane
//----------------------------------------------------------------------------------------------------
constructor TPlane.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
LPanel:=TPanel.Create(Self);
LPanel.Left:=10;
LPanel.Top:=10;
LPanel.Width:=61;
end;

Greetings,
Ronald




end.
Tue, Jul 2 2013 2:12 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ronald,

<< I create a component with the name TCell it is based upon a TPanel. Then
I created a component TMessage based on TCell. In the Create method of
TMessage I create a TPanel with the parent Self. If I free the component I
get an error (translated): >>

I'm not seeing that here with 1.02:

unit Unit1;

interface

uses WebCore, WebForms, WebCtrls;

type

TCell = class(TPanel)
  private
  public
  constructor Create(AOwner: TComponent); override;
  end;

TPlane = class(TCell)
  private
  LPanel    :TPanel;
  public
  constructor Create(AOwner: TComponent); override;
  end;


  TForm1 = class(TForm)
     Button1: TButton;
     procedure Form1Create(Sender: TObject);
     procedure Button1Click(Sender: TObject);
  private
     aCell: TCell;
     aPlane: TPlane;
  public
     { Public declarations }
  end;

var
  Form1: TForm1;

implementation

//----------------------------------------------------------------------------------------------------
//TCell
//----------------------------------------------------------------------------------------------------
constructor TCell.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;


//----------------------------------------------------------------------------------------------------
//TPlane
//----------------------------------------------------------------------------------------------------
constructor TPlane.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
LPanel:=TPanel.Create(Self);
LPanel.Left:=10;
LPanel.Top:=10;
LPanel.Width:=61;
end;


procedure TForm1.Form1Create(Sender: TObject);
begin
  aPlane:=TPlane.Create(Self);
  aPlane.Left:=100;
  aPlane.Top:=100;
  aPlane.Height:=300;
  aPlane.Width:=300;
  aPlane.Show;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  aPlane.Free;
end;

end.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 3 2013 3:19 AMPermanent Link

Ronald

Tim fixed the problem.

"Ronald"  schreef in bericht
news:8FC1B065-3522-4560-BD5A-B9255C8A9A73@news.elevatesoft.com...

Hi,

I create a component with the name TCell it is based upon a TPanel. Then I
created a component TMessage based on TCell. In the Create method of
TMessage I create a TPanel with the parent Self. If I free the component I
get an error (translated):

Can not get the property tfont_fname of an empty value...

I do not get the error if I set the parent of TPanel to AOwner (instead of
Self).

How can I solve this?


TCell = class(TPanel)
  private
  public
  constructor Create(AOwner: TComponent); override;
  end;

TPlane = class(TCell)
  private
  LPanel    :TPanel;
  public
  constructor Create(AOwner: TComponent); override;
  end;


implementation


//----------------------------------------------------------------------------------------------------
//TCell
//----------------------------------------------------------------------------------------------------
constructor TCell.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;


//----------------------------------------------------------------------------------------------------
//TPlane
//----------------------------------------------------------------------------------------------------
constructor TPlane.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
LPanel:=TPanel.Create(Self);
LPanel.Left:=10;
LPanel.Top:=10;
LPanel.Width:=61;
end;

Greetings,
Ronald




end.
Image