Solved

runtime pagecontrol with fixed tabsheets on variable number of runtime created tabsheets

Posted on 2008-10-20
5
456 Views
Last Modified: 2013-11-23
Hi
My app creates a variable number of tabsheets at runtime onto a designtime pagecontrol.  That part work fine.  These tabsheets all have the designtime pagecontrol as parent.

the app needs to create a unique 5 tabsheet pagecontrol on each tabsheet created at runtime.
I am not sure how to assign the created pagecontrols to the parent tabsheet of the first pagecontrol.
The only object on each of the 5 tabsheets is a grid of unique records populated before the pagecontrils are displayed.

Do I need to free all the created tabsheets and pagecontrols manually?



0
Comment
Question by:ajtsoukalas
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 22761399
depends how you create them. if you use

whatever.create(soemthing);

then no. if you use

whatever.create(nil);

then, maybe. I say maybe, because you can still add all of them to a TObjectList created with .create(true); and that will take care of freeing them. but that again requires code from you, first to create the object list, then to add everything created with nil to it and finally to destroy the object list.

I would recommend using the first way: create(something).

where something can be any tcomponent or descendant, really. usually you would use the same component which is the parent as well since once the parent dies, there is no sense (usually) for the child to live.
0
 

Author Comment

by:ajtsoukalas
ID: 22761603
Ok,
How does one reference the created tabsheet as the parent in the create method?  I'm not sure exactly how to do that.

AJ
0
 

Author Comment

by:ajtsoukalas
ID: 22761686
Sorry,
Stupid question.

What do I use as the argument for the new pagecontrols and the new tabsheets create method to avoid having to deal with it myself?

I know how to reassign the parent of those objects.
0
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 22761821
let's assume the parent is "blabla" (a component).

you will do:

page:=tpagecontrol.create(blabla);
page.parent:=blabla;
tab1:=ttabsheet.create(page);
tab1.parent:=page;
get it?

I don't know who is the parent of who (maybe it's the late hours here) so I cannot give you specific example for your code, but hopefully you can logically transcribe the "blabla" to your actual code :)
0
 

Author Closing Comment

by:ajtsoukalas
ID: 31507975
ciuly,
I was trying to borrow code from another pagecontrol question and should have realized that I needed to assign the create to a variable in order to use it later.

Thanks
aj


Thanks


0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question