H
Henry Wu
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 (
http://wuhenry.beigetower.org/position.zip ).
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
frmForm2.Invalidate()
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) -
iCaptionHeight
If frmForm2.Width <> iWidth Or frmForm2.Height <> iHeight
Then
frmForm2.Size = New Size(iWidth, iHeight)
frmForm2.Invalidate()
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
MDI-Container?
Thanks,
Henry
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 (
http://wuhenry.beigetower.org/position.zip ).
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
frmForm2.Invalidate()
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) -
iCaptionHeight
If frmForm2.Width <> iWidth Or frmForm2.Height <> iHeight
Then
frmForm2.Size = New Size(iWidth, iHeight)
frmForm2.Invalidate()
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
MDI-Container?
Thanks,
Henry