OK Thsnks for your help, I can now add the frames at runtime
I am adding them in the formShow event at the moment just for testing.
I still can't access the frame's sub components.
As you can see I am setting the subcomponents true.
How do I access these properties from my main form?
In my main form show event I load up 8 instances of the frame:
procedure TfmFuseConfig.FormShow(Sender: TObject);
Var i: Integer;
begin
for i := 0 to 7 do
AddFuseItem(i);
end;
procedure TfmFuseConfig.AddFuseItem(pIndex: Integer);
begin
FuseList := TFrmFuse.Create(Self);
with FuseList do
begin
Parent := Self;
Visible := True;
Align := alTop;
Name := 'FuseNo' + IntToStr(pIndex);
end;
end;
This leaves me with 8 frames visible on my form, I assume with Names of
FuseNo0 throught to FuseNo7.
How do I access these frames and their sub components? I have tried
populating their properties in the AddFuseItem procedure but I just get a
syntax error saying undeclared identifier.
E.g.
procedure TfmFuseConfig.AddFuseItem(pIndex: Integer);
begin
FuseList := TFrmFuse.Create(Self);
with FuseList do
begin
Parent := Self;
Visible := True;
Align := alTop;
Name := 'FuseNo' + IntToStr(pIndex);
ItemDesc.Caption := Name;// this line errors......
end;
end;
This is the source for the frame...........................................
unit PICFuseItem;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TfrmFuse = class(TFrame)
pnlFuseEntry: TPanel;
cmbValue: TComboBox;
pnlName: TPanel;
pnlDescription: TPanel;
private
{ Private declarations }
public
{ Public declarations }
Constructor Create(AOwner: TComponent);
property ItemName: TPanel Read pnlName Write pnlName;
property ItemValues: TComboBox Read cmbValue Write cmbValue;
property ItemDesc: TPanel Read pnlDescription Write pnlDescription;
end;
implementation
{$R *.dfm}
Constructor TfrmFuse.Create(AOwner: TComponent);
begin
inherited;
pnlName.SetSubComponent(True);
cmbValue.SetSubComponent(True);
pnlDescription.SetSubComponent(True);
end;
end.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of zayin
Sent: 30 June 2007 02:10
To: 'Borland's Delphi Discussion List'
Subject: RE: Component or Frame Arrays
Oh,
And I forgot. As to the array.
Sure you can make an array if you want, static if you know that bound or
dynamic if not.
Or a TList. That is what I would use.
var
frameList:TList;
frameList:=TList.Create;
..loop
FuseList := TFrmFuse.Create(Self);
frameList.Add(FuseList);
with FuseList do
And in the destroy or close of the form, walk the frameList and free all the
frames.
Ciao,
Mark
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi