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:
Private Declare Auto Function SetWindowLong Lib "User32.Dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Declare Auto Function GetWindowLong Lib "User32.Dll" (ByVal hWnd As System.IntPtr, ByVal nIndex As Integer) As Integer
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CLIENTEDGE = &H200
Then add the following to the MDI Parent's load event:
vb.net Code:
' SET BACKGROUND COLOR AND REMOVE BORDER FROM MDICLIENT CONTROL
For Each c As Control In Me.Controls()
If TypeOf (c) Is MdiClient Then
c.BackColor = Color.DimGray
Dim windowLong As Integer = GetWindowLong(c.Handle, GWL_EXSTYLE)
windowLong = windowLong And (Not WS_EX_CLIENTEDGE)
SetWindowLong(c.Handle, GWL_EXSTYLE, windowLong)
c.Width = c.Width + 1
Exit For
End If
Next
1 Attachment(s)
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:
Attachment 119077
Thanks in advance.
Quote:
Originally Posted by
circuits2
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:
Private Declare Auto Function SetWindowLong Lib "User32.Dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Declare Auto Function GetWindowLong Lib "User32.Dll" (ByVal hWnd As System.IntPtr, ByVal nIndex As Integer) As Integer
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_CLIENTEDGE = &H200
Then add the following to the MDI Parent's load event:
vb.net Code:
' SET BACKGROUND COLOR AND REMOVE BORDER FROM MDICLIENT CONTROL
For Each c As Control In Me.Controls()
If TypeOf (c) Is MdiClient Then
c.BackColor = Color.DimGray
Dim windowLong As Integer = GetWindowLong(c.Handle, GWL_EXSTYLE)
windowLong = windowLong And (Not WS_EX_CLIENTEDGE)
SetWindowLong(c.Handle, GWL_EXSTYLE, windowLong)
c.Width = c.Width + 1
Exit For
End If
Next
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.
Re: How to remove MDI Client Border
Re: How to remove MDI Client Border
Many years later, the code still works as well. Thank you very much.