-
Apr 8th, 2013, 08:59 AM
#1
Thread Starter
Frenzied Member
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
-
Sep 25th, 2014, 06:23 PM
#2
New Member
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:
Thanks in advance.
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
-
Dec 30th, 2014, 04:57 PM
#3
Thread Starter
Frenzied Member
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.
-
Aug 16th, 2018, 03:21 PM
#4
New Member
Re: How to remove MDI Client Border
-
Mar 1st, 2024, 07:55 PM
#5
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|