Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

Embedding child forms

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
nnbbb09
Asked:
nnbbb09
  • 2
  • 2
1 Solution
 
Phoenix_sCommented:
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
 
nnbbb09Author Commented:
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
 
kretzschmarCommented:
simple use yourformobject.parent := panel1;
0
 
kretzschmarCommented:
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
 
nnbbb09Author Commented:
Thanks Meikl.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now