Board index » delphi » embed a form into another form

embed a form into another form

who can create a form as another form's child.Using borland c++ ,this
task is very easy,but using delphi or vb I'm confused.

 

Re:embed a form into another form


Quote
In article <31A93461.3...@bbs.net.tsinghua.edu.cn> HuangBo <hbb....@bbs.net.tsinghua.edu.cn> writes:
>From: HuangBo <hbb....@bbs.net.tsinghua.edu.cn>
>Subject: embed a form into another form
>Date: Sun, 26 May 1996 21:49:37 -0700
>who can create a form as another form's child.Using borland c++ ,this
>task is very easy,but using delphi or vb I'm confused.

 you have to overide the form's createparams & loded methods. There is a good
eg in the Delphi Developers Guide, else there were postings here recently

HTH

Boris Ingram, Cyborg Software
boris...@iafrica.com
Compuserve : 100076, 3616
http://www.pcb.co.za/users/borising/cyborg.htm

Re:embed a form into another form


There are two ways I know to do this.

1. If you intend your form to be a control and register it, you need
to override Create to ensure the form has a parent before its Create
is called (this requires you to assume that AOwner supplied to Create
is a TWinControl, but I've yet to see this assumption fail) and
CreateParams to strip some flags which would make your form look like
a resizable window.
(In Delphi 2 it's not necessary to override Create - it seems to work
even without a parent).

2. If you just want to embed a form at run-time, you can use code such
as this:
  newform := TYourFormClass(TYourFormClass.NewInstance);
  with newform do begin
    Parent := Self;
    Create(Self);
  end;
This is similar to what goes on in Application.CreateForm, and as far
as I know it's harmless and produces the expected result. Again, you
may want to set newform's style to bsNone, otherwise it'll have a
window border.

HTH,
Ido Feldmann
(feld...@ibm.net).

On Sun, 26 May 1996 21:49:37 -0700, HuangBo

Quote
<hbb....@bbs.net.tsinghua.edu.cn> wrote:
>who can create a form as another form's child.Using borland c++ ,this
>task is very easy,but using delphi or vb I'm confused.

Re:embed a form into another form


I use panels in different windows and set their Parent properties to
another form or to individual pages in a TNotebook in another form. I do
this to split the source into several files.

--
Bent Tranberg, Agder College, Grimstad
Grooseveien 36, 4890 Grimstad, Norway
e-mail: Bent.Tranb...@hia.no

Re:embed a form into another form


Quote
In article <31AABD7E.4...@hia.no> Bent Tranberg <Bent.Tranb...@hia.no> writes:
>From: Bent Tranberg <Bent.Tranb...@hia.no>
>Subject: Re: embed a form into another form
>Date: Tue, 28 May 1996 10:46:54 +0200
>I use panels in different windows and set their Parent properties to
>another form or to individual pages in a TNotebook in another form. I do
>this to split the source into several files.

------------
In D2 I use a page control and set the TabVisible property to false for each
page. This approach has its pros and cons as the controls have their names in
the same scope as the main form and will result in a large source file for
the main form. Most useful for non-modal situations when you want some
or all of the main form controls to remain active (e.g. control panel style
interfaces). Controls on non-active pages are defacto disabled (at least as
far as the user is concerned).

If you want the secondary form to be modal, just set its position on create.
This approach allows you to serarate the code into another file and makes the
code generally more reusable.

A third approach- messier but sometimes useful - is to have a lot of invisible
controls and to move them into position (e.g. on a panel) just before making
them visible. Make the main form large for editing and set it to the runtime
size in the OnCreate method.

HTH

Other Threads