Tricking Transparent Non-Mdi Child Forms into MDI Parent / Application

Tricking Transparent Non-Mdi Child Forms into MDI Parent / Application

Post by henrycorte » Fri, 25 Jun 2004 18:09:25

Hi, I am aware that TransparencyKey only works with top-level forms or
Non-MDI Child Forms, if one tries to set the opacity or
transparencykey property to a MDI-Child form, it will have no effect.

So, I tricked my Transparent Non-MDI Child form into my MDI-Container
form via SetParent API as seen here in my VB.NET sample ( ).

I thought my problems are over, but apprently, even though I SetParent
the Transparent Non-MdiChild form to the MDI-Container form, the
Non-MdiChild form still retains its .Left & .Top coordinate systems to
Screen Coordinates.

So I tried using the SetForm2Location() function I made and place them
at Form1_Move event, so whenever Form1 moves, Form2 (transparent form)
will move to the same location of Form1.
Public Sub SetForm2Location()
If frmForm2 Is Nothing = False Then
Dim p As Point
p = frmForm1.PointToScreen(New System.Drawing.Point(0, 0))

frmForm2.Left = p.X
frmForm2.Top = p.Y

End If
End Sub
**form2 being the Transparent-Non-MdiChild
**form1 being the Mdi-Child

The main goal of my program is to make the Transparent-Non-MdiChild &
Mdi-Child forms to appear as though they are one and the same. Having
the same size & location.

Having the same size for both forms, I use the following code, which
works ok.
Public Sub SetForm2Size()
If frmForm2 Is Nothing = False Then
Dim iWidth As Integer
Dim iHeight As Integer

iWidth = frmForm1.Width - (iX_SFrame * 2)
iHeight = frmForm1.Height - (iY_SFrame * 2) -

If frmForm2.Width <> iWidth Or frmForm2.Height <> iHeight
frmForm2.Size = New Size(iWidth, iHeight)
End If
End If
End Sub
**placing the SetForm2Size at the Form1_Resize event, so whenever
Form1 resizes, Form2 will resize too (same size).

It appears to be when I MAXIMIZE the MDI-Container form, everyting is
appears OK, when I resize the Form1, Form2 resizes, when I move Form1,
Form2 moves on the same place, nice & good.

However, when I DONT maximize the MDI-Container form, location
problems occur. Moving form1 will move form2, but in a different
location, not at the same location of form1.

It appears that when I maximize the MDI-Container form, the coordinate
system becomes screen coordinates???? which made everything work ok.
Any ideas on what might have gone wrong when I don't maximize the


1. MDI - how to open a child from a child within MDI parent form?

2. MDI question - how to call other MDI child forms from a MDI chilid form?

Hi all. I have a MDI child form that is a systems maintenance form. I have
7 buttons that will be used to call 7 lookup table maintance forms. My code
to call the lookup table child forms from the child form is the problem.
How do I code it?
The MainFrame.vb is the MDI container. I tried setting that as the MdiParent
but no joy... Obviously I can't use .Me as .Me is a child form also.. So
how do I do this?

Thanks in advance..


Here is the one that calls the maintence form for Color:

Private Sub btnColor_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnColor.Click

Dim frmCOL As New frmColorMaint

frmCOL.MdiParent = GRS2.MainForm <------- this is the MainFrame.vb
that is the MDI container


End Sub

3. How do I write to the MDI Parent statusbar from a MDI child form?

4. MDI - how to open a child from a child within MDI parent?

5. Dragging a non-MDI child form off its parent container

6. Opening MDI Child From MDI Child Form, like VisStudio Start Page

7. Calling MDI child from a dotnet MDI parent

8. Using MDI child (in C++) from an dotnet MDI parent

9. Navigation between MDI Parent and MDI Child

10. MDI Parent to MDI Children

11. Is a Managed MDI child possible from a WIN32 MDI parent?

12. How do you bring MDI child windows to the front if MDI parent has controls?

13. MDI Parent and MDI Child

14. Prevent MDI child from going outside visible area of MDI parent?

15. Problem showing MDi Child if Picture on MDI Parent ?