Board index » delphi » Multiple forms within a single form window

Multiple forms within a single form window

2 questions:
How do I open a form so that it only opens within a main form window?

How do I open a single form many times at once eg when comparing sets of
nearly identical data?

 

Re:Multiple forms within a single form window


Hi Iain,

  sounds like you need to be making MDI applications - look at the FormStyle
property of your form, and the help on MDI (Multiple Document Interface)

Regards,

Matt Palmer.

Iain George MacGranthin <i_georg...@email.msn.com> wrote in message
news:7s24jj$3ou8@forums.borland.com...

Quote

Re:Multiple forms within a single form window


Quote
> How do I open a form so that it only opens within a main form window?

This is the typical domain of MDI programs. If your child forms are all
identical or nealry so (but you may have several instances of each) then
making the main form a MDI frame window and the child forms MDI child
windows may serve well. Delphi has a MDI project template you can use as a
start (New..|Projects|MDI Application).

Quote
> How do I open a single form many times at once eg when comparing sets of
> nearly identical data?

You do not autocreate these forms, you create several instances of the
form class in code, e.g.

 with TChildForm.Create( Application ) Do Begin
   ...setup forms data
   Show;
 end;  

To create several forms you simply repeat this with statement as often as
needed. Note that there is no form variable to which the created form
references are assigned. A single variable would be no use anyway, and if
the TChildForms are MDI child forms they are automatically added to the
main forms MDIChildren array, where you can look them up at need. However,
you should give each a unique Name or Tag or some other identifying data,
since they are all of the same class.

MDI has its limitations and quirks (build into Windows mostly), so you may
want to try some homegrown alternatives. A fairly simply one would be to
just create normal, non-MDI forms and set their Parent property to the
main form (not MDI also). This turns the forms into controls, which are
automatically confined to their parents client area. They loose some of
the typical form behaviour in the process (no OnActivate/OnDeactivate/
OnCloseQuery events, for instance, no working key preview handlers, but
that can be fixed in code) and you would have to write code to tile and
cascade these child windows (see API TileWindows, CascadeWindows) and
build a windows menu. But as a tradeoff you can do things like hiding
child windows at will, which would tie MDI into knots <g>.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads