Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can inherited controls appear at design time? 1

Status
Not open for further replies.

liamlaurent

IS-IT--Management
Oct 30, 2006
30
DM
Hi everyone,

I have a base form that I want all my other forms to inherit controls from (trying to cut down on design time). It has a page control a tool bar, a DBGrid and a few other controls. However when I set the other forms to inherit from it:

e.g
TfrmChemicals = class(TFrmBase)

the controls only appear at run time. This is gonna make it hard to place the other controls on the form that is inheriting TFrmBase's controls. Is there any way I could get them to appear at design time?

Liam
 
I would say No. But you can make a dummy form and get the positions from that.

But you can always design a form and leave it out of autocreate, then as many copies as you like at runtime.
e.g.
with TCodeEd.create(self) do
etc




Steve [The sane]: Delphi a feersum engin indeed.
 
When using the Create(Self) do you have to explicitly destroy each object when you're done with it?

Thanks,
les
 
how do u change the ancestral class

TfrmChemicals = class(TForm)

to

TfrmChemicals = class(TFrmBase)

just typping?

if so, try this

1) create the base form
2)file, new, other
3)in this dialog window look for a tabsheet wose caption is your project
4) chose the base form icon

 
Have a look at TFrame as your base class. They are MUCH easier to manage in the way you are using Forms. From Delphi help (Working with frames):
A frame (TFrame), like a form, is a container for other components. It uses the same ownership mechanism as forms for automatic instantiation and destruction of the components on it, and the same parent-child relationships for synchronization of component properties.

In some ways, however, a frame is more like a customized component than a form. Frames can be saved on the Component palette for easy reuse, and they can be nested within forms, other frames, or other container objects. After a frame is created and saved, it continues to function as a unit and to inherit changes from the components (including other frames) it contains. When a frame is embedded in another frame or form, it continues to inherit changes made to the frame from which it derives.

Frames are useful to organize groups of controls that are used in multiple places in your application. For example, if you have a bitmap that is used on multiple forms, you can put it in a frame and only one copy of that bitmap is included in the resources of your application. You could also describe a set of edit fields that are intended to edit a table with a frame and use that whenever you want to enter data into the table.
 
Or replying to the form-inheritance: Just open your descendant and do a right-click on the form and select "Show as text". There replace the first word ("object") by "inherited". After that do a right-click and select "Show formular". After this steps you should see your components on the base form on the descendant.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top