Results 1 to 21 of 21

Thread: Opacity/Invisibility of a form inside a MDI form

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Question 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!!
    Attached Images Attached Images  

  2. #2
    Member cyberM's Avatar
    Join Date
    Mar 2009
    Location
    Croatia , Zagreb
    Posts
    61

    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
    If you satisfied add to reputation





    PhotoResizer GDI+Shape form,shape inside

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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.

  4. #4
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    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...

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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

  6. #6
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: Opacity/Invisibility of a form inside a MDI form

    Do you want the controls to be opaque or transparent, like the form?

  7. #7
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    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

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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.

  9. #9
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: Opacity/Invisibility of a form inside a MDI form

    um, now this just piqued my curiosity...

    What are you trying to do?

  10. #10
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: Opacity/Invisibility of a form inside a MDI form

    Did you want the scroll bars on the bottom and right sides?

  11. #11

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Opacity/Invisibility of a form inside a MDI form

    no, not actually. But I can just disable it.

  12. #12

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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.

  13. #13
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    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.)

  14. #14

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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).

  15. #15
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    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.
    Attached Images Attached Images  

  16. #16

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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

  17. #17
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    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.

  18. #18

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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

  19. #19
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: Opacity/Invisibility of a form inside a MDI form

    Try This.

  20. #20

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    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.

  21. #21
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width