Results 1 to 5 of 5

Thread: How to remove MDI Client Border

  1. #1

    Thread Starter
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    How to remove MDI Client Border

    I will add more of an explanation later.

    This is how you can remove the border and set the backcolor of the MDIClient control, which is the control that is automatically added to your form when you set its IsMdiContainer property to True.


    Add the following inside your class:

    vb.net Code:
    1. Private Declare Auto Function SetWindowLong Lib "User32.Dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    2. Private Declare Auto Function GetWindowLong Lib "User32.Dll" (ByVal hWnd As System.IntPtr, ByVal nIndex As Integer) As Integer
    3. Private Const GWL_EXSTYLE = (-20)
    4. Private Const WS_EX_CLIENTEDGE = &H200


    Then add the following to the MDI Parent's load event:

    vb.net Code:
    1. ' SET BACKGROUND COLOR AND REMOVE BORDER FROM MDICLIENT CONTROL
    2. For Each c As Control In Me.Controls()
    3.     If TypeOf (c) Is MdiClient Then
    4.         c.BackColor = Color.DimGray
    5.         Dim windowLong As Integer = GetWindowLong(c.Handle, GWL_EXSTYLE)
    6.         windowLong = windowLong And (Not WS_EX_CLIENTEDGE)
    7.         SetWindowLong(c.Handle, GWL_EXSTYLE, windowLong)
    8.         c.Width = c.Width + 1
    9.         Exit For
    10.     End If
    11. Next
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  2. #2
    New Member
    Join Date
    Sep 2014
    Posts
    1

    Re: How to remove MDI Client Border

    Hey bro!

    Taking your code as example, finally got something I wanted to do a few weeks ago.

    However, I'm using the "Padding" property to change my Form design. When I do this, the color of the background has splitted in two parts, inside and outside of the MDI container.

    Is this normal? is there a way to fix this?

    This is it:

    Name:  Captura.jpg
Views: 4866
Size:  8.6 KB

    Thanks in advance.

    Quote Originally Posted by circuits2 View Post
    I will add more of an explanation later.

    This is how you can remove the border and set the backcolor of the MDIClient control, which is the control that is automatically added to your form when you set its IsMdiContainer property to True.


    Add the following inside your class:

    vb.net Code:
    1. Private Declare Auto Function SetWindowLong Lib "User32.Dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    2. Private Declare Auto Function GetWindowLong Lib "User32.Dll" (ByVal hWnd As System.IntPtr, ByVal nIndex As Integer) As Integer
    3. Private Const GWL_EXSTYLE = (-20)
    4. Private Const WS_EX_CLIENTEDGE = &H200


    Then add the following to the MDI Parent's load event:

    vb.net Code:
    1. ' SET BACKGROUND COLOR AND REMOVE BORDER FROM MDICLIENT CONTROL
    2. For Each c As Control In Me.Controls()
    3.     If TypeOf (c) Is MdiClient Then
    4.         c.BackColor = Color.DimGray
    5.         Dim windowLong As Integer = GetWindowLong(c.Handle, GWL_EXSTYLE)
    6.         windowLong = windowLong And (Not WS_EX_CLIENTEDGE)
    7.         SetWindowLong(c.Handle, GWL_EXSTYLE, windowLong)
    8.         c.Width = c.Width + 1
    9.         Exit For
    10.     End If
    11. Next

  3. #3

    Thread Starter
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: How to remove MDI Client Border

    Did you ever get that working the way you wanted? It's hard to tell what's going on without seeing the way you modified the code.
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  4. #4
    New Member
    Join Date
    Aug 2018
    Posts
    1

    Re: How to remove MDI Client Border

    it works wonders

  5. #5
    Member Taro's Avatar
    Join Date
    Feb 2014
    Posts
    33

    Re: How to remove MDI Client Border

    Many years later, the code still works as well. Thank you very much.

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