Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Components Usage > Delphi7: Insta...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 105 of 174
Post > Topic >>

Delphi7: Instancing controls (control-array) at runtime? plz help

by MWin@[EMAIL PROTECTED] (Mike Winauer) May 3, 2004 at 12:28 PM

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
 




 3 Posts in Topic:
Delphi7: Instancing controls (control-array) at runtime? plz he
MWin@[EMAIL PROTECTED] (  2004-05-03 12:28:14 
Re: Delphi7: Instancing controls (control-array) at runtime? pl
"Bruce Roberts"  2004-05-03 16:10:05 
Re: Delphi7: Instancing controls (control-array) at runtime? pl
"Tom de Neef" &  2004-05-04 16:05:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 3:01:08 CDT 2008.