I have a MDI form containing 2 other forms that I first created via GUI and than manually added to the MDI form.
Form1 = MDI form
Form2 = Form containing a WMP and button
Form3 = Form containing a butoon. This form's opacity is set to 50%, to make it semi invisible.
My MDI Form looks like this
Code:
Public Class Form1
Dim f As New Form2
Dim g As New Form3
Public WithEvents b As New Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
f.MdiParent = Me
g.MdiParent = Me
f.setSize(Me.Width, Me.Height)
g.setSize(Me.Width, Me.Height)
f.Show()
g.Show()
End Sub
End Class
But when I add Form3 (Dim g as shown above) to the MDI Form it isn't semi-invisible like when I compile Form3 alone, but is 100% visible (as in the screenshot).
Does anyone have a clue how to make it semi-invisible/invisible when I add it to the MDI form??
Re: Opacity/Invisibility of a form inside a MDI form
this is VB 6.0 code, but it will back the background transparent, but not the controls:
Use the setwindowrgn api call, this allows painting of the window only within the specified region(s). In this example, all controls and the titlebar are made part of the paintable region, the background isn't.
Code:
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Const RGN_OR = 2
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private NewRgn As Long
Private IsDrag As Boolean
Private RelX, RelY As Integer
Private Sub CloseButton_Click()
Unload Me
End Sub
Private Sub Dragger_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsDrag = True
RelX = X
RelY = Y
End Sub
Private Sub Dragger_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If IsDrag = True Then
Left = Left + X - RelX
Top = Top + Y - RelY
End If
End Sub
Private Sub Dragger_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsDrag = False
End Sub
Private Sub Form_Load()
tx = Screen.TwipsPerPixelX
ty = Screen.TwipsPerPixelY
NewRgn = CreateRectRgn(0, 0, 0, 0)
For I = 0 To Controls.Count - 1
AddingRgn = CreateRectRgn(Controls(I).Left / tx, Controls(I).Top / ty, (Controls(I).Left + Controls(I).Width) / tx, (Controls(I).Top + Controls(I).Height) / ty)
CombineRgn NewRgn, AddingRgn, NewRgn, RGN_OR
Next
SetWindowRgn hWnd, NewRgn, False
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowRgn hWnd, 0, False
DeleteObject NewRgn
End Sub
Re: Opacity/Invisibility of a form inside a MDI form
I want a MDI form with 2 child frames in it.
The 1st child form is at the back, The second one is on top of the first one, but the opacity = 0.00001, hence the second child form is transparant.
Then I want to give the transparent form a on-click event handler.
Thus you can see any contols on the 1st form (because the top form is transparent), but when you click anywhere (even on buttons, textboxes, etc) the event of the transparent form is called.
Re: Opacity/Invisibility of a form inside a MDI form
Ahhhh...
How about creating a sub to handle all the 'clicks':
Code:
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Form1.Click, Form1.WindowsMediaPlayer1.Click, Form1.Button1.Click
msgbox("Something has been clicked.")
End Sub
That might be long winded, but it would solve your problem. (I think.)
Re: Opacity/Invisibility of a form inside a MDI form
Select the WMP Control.
Click on the little lightning bolt in the Properties Dialog Box
Scroll down to DoubleClickEvent
If you Double-Click on that entry, it will create a sub handling the doubleclickevent.
Re: Opacity/Invisibility of a form inside a MDI form
I want to do some opperations when a user double-clicks on WMP while playing.
I just want to disable the default WMP double-click operation and REPLACE it with my own
Re: Opacity/Invisibility of a form inside a MDI form
I'm sorry I couldn't help more. I don't have that problem... Every time I double click on it, my code gets run and nothing else happens. Even if I remove the whole double click event, it still doesn't switch into full screen. That's why I was thinking it may be something like the codec.