1 Attachment(s)
Opacity/Invisibility of a form inside a MDI form
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??
Thank you!!
Re: Opacity/Invisibility of a form inside a MDI form
For easyer understanding try this
Form3.FormBorderStyle = FormBorderStyle.None
Form3.BackColor = same as background
For something other you will going in system drawing.namespace.
Take closer look on my work about form
http://www.pscode.com/vb/scripts/Sho...7010&lngWId=10
Re: Opacity/Invisibility of a form inside a MDI form
This won't work, because I want a colourless form (or transparent) and not one that just looks likes the backgroung of another form.
I studied your code (it's cool, I'll remeber that for the future), but it's not what I'm currently looking for. but thanx anyway.
Re: Opacity/Invisibility of a form inside a MDI form
So you want it to still be there (colored and everything) yet it is see-through?
I'll see what I can do, but I doubt that you can do that. I could be wrong, though...
Re: Opacity/Invisibility of a form inside a MDI form
Sort of. I just want to change the opacity of one form. This works, but not in an MDI form.
Thanx
Re: Opacity/Invisibility of a form inside a MDI form
Do you want the controls to be opaque or transparent, like the 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:
Quote:
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
Don't ask why, but there will be no controls on the transparent form, thus the transparant form will be empty.
Re: Opacity/Invisibility of a form inside a MDI form
um, now this just piqued my curiosity...
What are you trying to do? :confused::p
Re: Opacity/Invisibility of a form inside a MDI form
Did you want the scroll bars on the bottom and right sides?
Re: Opacity/Invisibility of a form inside a MDI form
no, not actually. But I can just disable it.
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
I actually want to overload the double-click event.
The 1st thought was the same as yours, but you can't overload the double-click event of WMP, don't know why not, but you can't (or I don't know how).
1 Attachment(s)
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
That only works if there isn't a movie playing.
If you play a movie and double click, WMP enters full screen and doen't call your event
Re: Opacity/Invisibility of a form inside a MDI form
Display a message box saying that Fullscreen has been disabled, or something, in the double click event. That works for me.
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
Re: Opacity/Invisibility of a form inside a MDI form
They say the problem may be with the codecs.
I don't want to change any codec or windwos settings.
So I'm back at the first problem - transparent form
But thanks, you realy helped alot.
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.
Anyhow, I hope you get this figured out!