Solved

Embedding child forms

Posted on 2001-09-07
5
214 Views
Last Modified: 2010-04-06
I would like to be able to embed child forms inside a panel on the parent form. Previously I used to achieve this by using mdi, but would like to avoid using that if possible. I currently do it by assigning the handle of the panel to the ParentWindow property of the child form. Although the child form appears ok and is usable, it's not sized correctly. Its aligned alClient so should fill the contents of the panel but seems to be to wide and an tall. Have I missed something or is there a better way of embedding forms.

Thanks

Jo
0
Comment
Question by:nnbbb09
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Phoenix_s
ID: 6464626
there's frames..  afaik they're available in delphi 5 and up.

here's a snippet about them from the d5 help file

When you create frames, they are implemented as descendants of TFrame.

A frame, 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. But frames can be nested within forms or other frames, and they can be saved on the Component palette for easy reuse. 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. Moreover, an embedded frame continues to inherit changes made to the frame from which it is derived.
0
 
LVL 3

Author Comment

by:nnbbb09
ID: 6464690
Phoenix s - Thanks, but I've already explored using frames. I'm using the Developer Express toolbar components and they must have a TCustomForm as their owner. Thanks anyway.

Jo
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6465072
simple use yourformobject.parent := panel1;
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 6465149
hi again,

a sample from a project of mine
(i've overloaded the constructor of my to embedding childform)

--part paste
...
  public
    Constructor Create(AOwner : TComponent;
                       AParent : TWinControl); OverLoad;
  end;

var
  frmac: Tfrmac;

implementation
{$R *.DFM}


Constructor Tfrmac.Create(AOwner : TComponent;
                          AParent : TWinControl);
begin
  Inherited Create(AOwner);
  Align := alClient;
  BorderStyle := bsNone;
  Parent := AParent;
  Show;
end;

....
-- part paste end
and i use for create
(even i must not use a reference var in my case)

  with TfrmAC.Create(self,panACSource) do;

other ways are also possible

meikl ;-)
0
 
LVL 3

Author Comment

by:nnbbb09
ID: 6465347
Thanks Meikl.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now