MDI Child Windows Overlapped by control on Parent

D

diego

Hello everyone.

I have an MDI form (parent) that has a number of controls on it. When I
display MDI child windows, the child windows appear behind the controls
that are on the parent window. How can make it so that the child window
are on top of the controls on the parent window.

Thanks in advance.

Diego
 
R

R. MacDonald

Hello, Diego,

I think that it is a bit unusual to put controls directly on the MDI
form. If you do they will always be on top, as you've noticed.

Is there some reason that you can't put your controls on a toolbar?

If you really must do something like this, the only possibility that I
can think of is to draw fake images of your controls on the MDIClient
and do all of your own processing of mouse and keyboard events to
simulate the behaviour of real controls.

To me, this sounds like far too much trouble, and it has the associated
risk that goes with the caveat in the documentation for the MDIClient
that says: "The MdiClient type supports the .NET Framework
infrastructure and is not intended to be used directly from your code."

Cheers,
Randy
 
D

diego

Hi Randy,

Thanks for your reply.

What I want to place on the MDI form is a Web browser control to
display a page from a pre-determined site. This page may contain
announcements, warnings, etc. for the users.

Is this possible?

Thanks in advance.

Deigo
 
R

R. MacDonald

Hello, Diego,

I don't think it is possible to do this directly. It would be easy to
put it onto some sort of a docked container control, but I guess this is
not what you want.

If the contents are for "display-only", and you do not need any active
controls on the MDI background you might be able to find a way to copy
the image of the Web page to the MDIClient.

I don't know offhand how you would get the image from the web page, but
if you can then you could do something like this:

Private WithEvents mFrame As MdiClient ' MDI Client window frame.

You will need to "find" the MDIClient. Maybe there are better ways, but
this has worked for me:

For Each ctlCurrent As Control In Me.Controls
If (TypeOf ctlCurrent Is MdiClient) Then
mFrame = DirectCast(ctlCurrent, MdiClient)
Exit For
End If
Next ctlCurrent

I have used this in the first pass of the MDI Form's Activate event, but
have recently learned that .Net 2005 provides a "Shown" event that may
be better for this.

Then, use the Paint event of the MDIClient to display the image of your
web page.

Private Sub MDIControl_Paint(ByVal sender As Object, _
ByVal e As PaintEventArgs) _
Handles mFrame.Paint
' Copy the image here using e.Graphics
. . .

End Sub

But again, don't forget the caveat that "The MdiClient ... is not
intended to be used directly from your code." And if you want to
simulate active controls on the MDI background, this will become much
more difficult. There might be better/easier ways to accomplish the
functionality that you want.

Good luck,
Randy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top