Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

child form inside of a panel

322 views
Skip to first unread message

Jens Gruschel

unread,
Apr 11, 2005, 12:23:36 PM4/11/05
to
Is there anyone having experience in creating forms inside of a panel?
If I set the Parent property of a form (created by code) to a Panel, the
form appears inside of the panel, I can drag it around inside of the
panel, but sometimes I get some graphics errors (especially when the
panel is resized). Any ideas?

Jens

Remy Lebeau (TeamB)

unread,
Apr 11, 2005, 3:29:36 PM4/11/05
to

"Jens Gruschel" <nos...@thisurldoesnotexist.com> wrote in message
news:425aa47b$1...@newsgroups.borland.com...

> Is there anyone having experience in creating forms inside of a panel?

Why are you re-parenting forms to begin with? Such operations should be
limited to MDI only, which is specifically designed for that. If MDI does
not suit your needs, then what exactly are you trying to accomplish in the
first place?


Gambit


Jens Gruschel

unread,
Apr 11, 2005, 3:46:35 PM4/11/05
to
> Why are you re-parenting forms to begin with? Such operations should be
> limited to MDI only, which is specifically designed for that. If MDI does
> not suit your needs, then what exactly are you trying to accomplish in the
> first place?

Probably you are right. I thought I could easily write my own MDI
mechanism. The main reason for this is, that I want the childs either be
separate windows or sheets of a page control. But probably this is
possible, too, with normal MDI applications, maybe using some docking
mechanism. But, well, everything works perfectly, except of this
occasional graphic errors, so I thought I could manage to get it working
with the help of someone, who has done something similar.

Jens

Remy Lebeau (TeamB)

unread,
Apr 11, 2005, 5:39:58 PM4/11/05
to

"Jens Gruschel" <nos...@thisurldoesnotexist.com> wrote in message
news:425ad40d$1...@newsgroups.borland.com...

> The main reason for this is, that I want the childs either
> be separate windows or sheets of a page control.

You should use frames for that. You can then place the frames on forms or
sheets as needed. That is the kind of thing that frames are meant for


Gambit


Brian Cook

unread,
Apr 12, 2005, 1:13:28 AM4/12/05
to

What is the error?


- Brian

Jens Gruschel

unread,
Apr 12, 2005, 5:37:09 AM4/12/05
to
> What is the error?

When a child form is visible only partial, and I increase the size of
the panel, making the child form visible completely, there are lines
(with a width of 2 pixels), which are not invalidated correctly. See
b.p.atachments (same subject). Maybe I better use a normal MDI approach,
but I think it's strange anyway (and should be possible, shouldn't it?).

Jens

Brian Cook

unread,
Apr 14, 2005, 1:30:03 AM4/14/05
to
> > What is the error?
>
> When a child form is visible only partial, and I increase the size of
> the panel, making the child form visible completely, there are lines
> (with a width of 2 pixels), which are not invalidated correctly. See
> b.p.atachments (same subject).

I hate problems like that. They can be *very* difficult to debug.


> Maybe I better use a normal MDI approach,
> but I think it's strange anyway (and should be possible, shouldn't it?).

I built a simple test program (Delphi 6) and it works. It was fairly
MDI-ish and there were no paint remnants.


The problem could be in the paint code (how are the "child" forms
painted?), a bug in the VCL, a bug in the operating system (Windows
2000), or a problem with the video system.


- Brian

Jens Gruschel

unread,
Apr 14, 2005, 4:04:25 AM4/14/05
to
> I built a simple test program (Delphi 6) and it works. It was fairly
> MDI-ish and there were no paint remnants.

That's a good hint, so probably it's a bug I created myself. Have to
look at all the methods overridden / messages catched / events handled
for both the container and the child forms.

> The problem could be in the paint code (how are the "child" forms
> painted?), a bug in the VCL, a bug in the operating system (Windows
> 2000), or a problem with the video system.

It's the same bug on Windows 2000 and XP, tested on 3 different PCs
(with 3 different graphic cards), so I guess it must be a bug in my
code. But switching off certain things (like background painting for the
container panel) did not help, so maybe it's a combination of two or
more "features". Starting a test project (like you've done) certainly
will help.

Jens

Andrew Jameson

unread,
Apr 14, 2005, 4:10:09 AM4/14/05
to
Hi Jens,
I don't think that you can simply set the parent of the form to be the panel
whilst preserving the form's non-client area (caption, etc) ... try setting
the BorderStyle of your parented form to bsNone. My reports manager app
uses a mass of forms that are parented by a panel without problem.

Andrew


Martin Schoellhammer

unread,
Apr 14, 2005, 5:13:03 AM4/14/05
to

We did something similar, and use the following code, didn't face any
problems:
constructor TEmbeddableForm.CreateEmbeddableForm(AOwner: TComponent;
parctrl : TWinControl );
begin
if parctrl <> Nil then begin (* embedded child window *)
FParentHandle := parctrl.Handle;
BorderIcons := [] ;
BorderStyle := bsNone ;
Align := alClient ;
SetBounds ( 0, 0, parctrl.Width, parctrl.Height ) ;
inherited Create(AOwner);
end
end

Martin

Martin B

unread,
Apr 23, 2005, 1:49:17 PM4/23/05
to
How do you use the FParentHandle variable?
Isn't it enough to set the Parent of the form to parctrl?

Martin B

unread,
Apr 24, 2005, 5:08:58 AM4/24/05
to

Martin B

unread,
Apr 25, 2005, 2:31:58 AM4/25/05
to
As Remy says, you can use Frames for that purpose.

Create a new Frame unit (in the File/New/Other... menu).
Copy all the controls and code (except FormCreate and Formshow) to
the new unit.
Now insert a frame control on the original form (this is a Standard
control).
Now you have a form that appears just the same as before, and you
can place the frame in a panel on a new form. Just again place a
frame control on the panel.
Very easy.

"Jens Gruschel" <nos...@thisurldoesnotexist.com> wrote in message

news:425aa47b$1...@newsgroups.borland.com...

Perry Kappetein

unread,
Sep 4, 2005, 4:57:09 AM9/4/05
to
This works great, but how can you make it work that when you press a button,
it appears.

so I have a few panels say Left Top and Bottom
when I click on the Button in my left Panel, I want my Tframe1 created/or
shown in my Top Panel
so, I don't want to see the frame on my screen while I am working on it,
since that panel will be used for other screens/setting to show.


"Martin B" <m...@mb.com> wrote in message
news:426c...@newsgroups.borland.com...

Martin B

unread,
Sep 4, 2005, 5:18:41 AM9/4/05
to
What you want is probably to create the frame or panel in runtime.
This tutorial may help:
http://www.delphi-central.com/runtime.aspx


0 new messages