Board index » delphi » Embedding a form in another form

Embedding a form in another form

Hi Delphites. Does anyone know how to embed one form within another so that
the embedded form appears as a panel would within the other form?

I am developing an application that makes heavy use of page controls to
switch between about 20 different views at run-time, but it makes for a
very large and complex main form. I want to design each view as a form, and
have it appear on a page as though the form's controls were actually
directly on that page. Does this make sense?

One of the problems I am having with everything on the main form is that I
cannot have the application open in Delphi and running at the same time,
because the system runs out of system resources (32Mb RAM laptop). Hence I
would like to abstract out each view into a form, but without the visual
appearance at run-time of being a separate window.

I would be really interested to hear views on this.

Regards,
Mark Stephens.

 

Re:Embedding a form in another form


What about making a page for each of the different views. (You should use
inheritance). Then you could display the individual page on the mainform
according to wich view is active. Place the different pages at their own
Forms, but in run time only show the MainForm, and "steal" the pages from
the other Forms.

Example:
TBaseViewFrm  => Simple Form with a PageControl with one empty page
TMyFirstView => inherited TBaseView with some extra stuff on it's page
            ...and so on
In your MainForm set PageCtrl.Parent to MainForm and voila you have it
displayed.
As you go through your views make sure to set the last displayed
PageCtrl.Parent back  to it's original one, and set the selected view's
PageCtrl.Parent to MainForm.

I've done this in an application I'm working with right now. If you want
some sample code I could email it to you.
--
Edgar Vorland

{Remove  '~' from mail adress. This is to avoid
spawn. Sorry! }
e~vorl...@readmatre.no

Mark Stephens <ma...@stconsult.co.nz> wrote in article
<01bcff85$ba011e60$08126...@actrix.gen.nz.actrix.gen.nz>...

Quote
> Hi Delphites. Does anyone know how to embed one form within another so
that
> the embedded form appears as a panel would within the other form?

> I am developing an application that makes heavy use of page controls to
> switch between about 20 different views at run-time, but it makes for a
> very large and complex main form. I want to design each view as a form,
and
> have it appear on a page as though the form's controls were actually
> directly on that page. Does this make sense?

> One of the problems I am having with everything on the main form is that
I
> cannot have the application open in Delphi and running at the same time,
> because the system runs out of system resources (32Mb RAM laptop). Hence
I
> would like to abstract out each view into a form, but without the visual
> appearance at run-time of being a separate window.

> I would be really interested to hear views on this.

> Regards,
> Mark Stephens.

Re:Embedding a form in another form


Mark -

Quote
>Hi Delphites. Does anyone know how to embed one form within another so that
>the embedded form appears as a panel would within the other form?

We are doing this a lot.  We got started by reading a paper by Jon Shemitz
called "Models, Views, and Frames."  We got the paper off the web, but it first
appeared in "High Performance Delphi 3 Programming."  I don't have the URL any
more, but try www.midnightbeach.com.

--
Clayton Neff
Software Project Leader
The Personal Marketing Company, Inc.
11843 West 83rd Terrace
Lenexa, KS  66214
(913)492-0322
clay...@tpmco.com

Other Threads