Mike Winauer
2004-05-03 19:28:14 UTC
Hi Newsgroup,
I'm using Delphi 7 Enterprise, and got following Problem:
I have a TabStrip(TPageControl), with 8 Pages(TTabSheet), that show
different stuff, but on top of every of those 8 TabSheets i need an
instance of a Frame (which contains 2 TextBoxes, 2 Labels, and an icon).
Now, i know i could drag'n'drop that frame on every TabSheet at
DesignTime, but i would like to do it at Runtime.
The Catch is, i need the contents of these 8 Instances of that Frame
(i.e. the texts of those 2 textboxes) synchronised, meaning, when i
enter a text in the textbox on TabSheet1, all other 7 TabSheet's
Frames should show the same text. That goes easier, if i can recurse
thru a List, rather run the same code 8 times one after another,
PLUS i dont know yet, if i wont have more than 8 pages some time)
The Frame i wanna instantiate, looks pretty much like this:
(frmProduktName.pas)
type
TProduktName = class(TFrame)
lblName: TLabel;
lblDescription: TLabel;
txtName: TEdit;
txtDescription: TEdit;
// plus some cosmetic controls (Bevel, Groupbox...)
private
{ Private declarations }
public
{ Public declarations }
end;
My approach was, building up a list at runtime, where every item
contains an instance of that frame, and a pointer to the next one:
(frmMain.Pas)
Type
pProdName = ^TProdName;
TProdName = record
frmForm : TProduktName; // <-- see above
Next : pProdName;
end;
that's how i tried to build up the list:
procedure CreateFrames();
var
pCurPName : pProdName;
tmpPName : TProduktName;
begin
// Create Instance of the Frame into TabSheet1
tmpPName := TProduktName.Create(frmMain.TabSheet1);
tmpPName.Align := alTop;
// Create ListEntry, Patch Frame into it
New(pCurPName);
pCurPName.Next := nil;
pCurPName.frmForm := tmpPName;
pFirstPName := pCurPName;
// then create the other 7 elements samy way and add em
// to the list, one by one
end;
Now, here's the thing: the Instance of the Frame creates just fine, the
browsing thru the instances worx too, they just won't show up in the
TabSheet. I can set/get the values of all it's properties (Height,
Top, Align, ...), but even tho Visible is true, it wont show, no matter
who's Repaint-Method i fire up (TForm, TTabSheet, TPageControl...)
It's pretty obvious i did this with the book on my lap, and i probably
just asked the most stupid question in the world, but this is my first
delphi project, and my last experience with pointers and lists goes
back to the good old Borland Pascal 7.0 times, so any help will be
greatly appreciated.
Or does anyone know another way to create a number of instances
of an object, or control-arrays in general?
(in VB it was so easy, create n controls of same type, give em same
name, ascending indexes and u got the control-array)
Thanx a lot in advance,
Mike Winauer
I'm using Delphi 7 Enterprise, and got following Problem:
I have a TabStrip(TPageControl), with 8 Pages(TTabSheet), that show
different stuff, but on top of every of those 8 TabSheets i need an
instance of a Frame (which contains 2 TextBoxes, 2 Labels, and an icon).
Now, i know i could drag'n'drop that frame on every TabSheet at
DesignTime, but i would like to do it at Runtime.
The Catch is, i need the contents of these 8 Instances of that Frame
(i.e. the texts of those 2 textboxes) synchronised, meaning, when i
enter a text in the textbox on TabSheet1, all other 7 TabSheet's
Frames should show the same text. That goes easier, if i can recurse
thru a List, rather run the same code 8 times one after another,
PLUS i dont know yet, if i wont have more than 8 pages some time)
The Frame i wanna instantiate, looks pretty much like this:
(frmProduktName.pas)
type
TProduktName = class(TFrame)
lblName: TLabel;
lblDescription: TLabel;
txtName: TEdit;
txtDescription: TEdit;
// plus some cosmetic controls (Bevel, Groupbox...)
private
{ Private declarations }
public
{ Public declarations }
end;
My approach was, building up a list at runtime, where every item
contains an instance of that frame, and a pointer to the next one:
(frmMain.Pas)
Type
pProdName = ^TProdName;
TProdName = record
frmForm : TProduktName; // <-- see above
Next : pProdName;
end;
that's how i tried to build up the list:
procedure CreateFrames();
var
pCurPName : pProdName;
tmpPName : TProduktName;
begin
// Create Instance of the Frame into TabSheet1
tmpPName := TProduktName.Create(frmMain.TabSheet1);
tmpPName.Align := alTop;
// Create ListEntry, Patch Frame into it
New(pCurPName);
pCurPName.Next := nil;
pCurPName.frmForm := tmpPName;
pFirstPName := pCurPName;
// then create the other 7 elements samy way and add em
// to the list, one by one
end;
Now, here's the thing: the Instance of the Frame creates just fine, the
browsing thru the instances worx too, they just won't show up in the
TabSheet. I can set/get the values of all it's properties (Height,
Top, Align, ...), but even tho Visible is true, it wont show, no matter
who's Repaint-Method i fire up (TForm, TTabSheet, TPageControl...)
It's pretty obvious i did this with the book on my lap, and i probably
just asked the most stupid question in the world, but this is my first
delphi project, and my last experience with pointers and lists goes
back to the good old Borland Pascal 7.0 times, so any help will be
greatly appreciated.
Or does anyone know another way to create a number of instances
of an object, or control-arrays in general?
(in VB it was so easy, create n controls of same type, give em same
name, ascending indexes and u got the control-array)
Thanx a lot in advance,
Mike Winauer