Results 1 to 3 of 3

Thread: [RESOLVED] Transparent MDI-Parent?

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Resolved [RESOLVED] Transparent MDI-Parent?

    I know you can make certain parts of a form transparent by setting the transparencyKey of the form to the color of your choice.
    vb.net Code:
    1. Me.MdiParent.TransparencyKey = Color.Fuchsia
    2. Me.BackColor = Color.Fuchsia

    Once I set the form to be a MDI Container, it seems to just ignore that function.

    On my MDI Container form I have a menu and that is the only thing I want displayed. I want the container itself to be transparent. The forms that get loaded into the mdicontainer will be shown normal.

    How can I do this?

  2. #2
    Hyperactive Member
    Join Date
    Apr 2011
    Location
    England
    Posts
    421

    Re: Transparent MDI-Parent?

    Hiya, the simplest approach, which I guess would be considered more of a Hack than a plausible solution, would be to do something like the following (I don't know what effect that will have on your Menu though):

    VB.NET Code:
    1. 'Create an MDIClient
    2. Private MyMDIClient As New MdiClient
    3. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         'Set the BackColor and Transparency Key for your form
    5.         Me.BackColor = Color.Red
    6.         Me.TransparencyKey = Me.BackColor
    7.  
    8.         'Add the MDIClient to your form and set its backcolor to match your form backcolor
    9.         MyMDIClient.BackColor = Color.Red
    10.         Me.Controls.Add(MyMDIClient)
    11.  
    12.         'Use Form1 as your MdiParent instead of the MDIClient
    13.         Dim f2 As New Form2
    14.         f2.MdiParent = Me
    15.         f2.Show()
    16. End Sub
    It may be possible to implement a more solid solution by creating your MDIClient by using the CreateWindowEx API. I've had a look over a few articles that point you towards creating an MDIClient but it is a pretty complex road to go down. If you would like to look further into it, here are a few articles that may help:

    http://www.pinvoke.net/default.aspx/...ex.html?diff=y
    http://www.experts-exchange.com/Prog..._24264982.html - Subscription Required to view solutions.
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    http://www.pinvoke.net/default.aspx/....getwindowlong - List of WindowStyle and ExtendedWindowStyle Constants

    Good luck and hope this helps

  3. #3

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: [RESOLVED] Transparent MDI-Parent?

    Thanks a lot for the code. I kinda feel stupid now seeing how easy this issue was to solve...
    Thanks again

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