I try to create a borderless form with this code
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
Me.FormBorderStyle = FormBorderStyle.None
Me.DoubleBuffered = True
Me.SetStyle(ControlStyles.ResizeRedraw, True)
End Sub
Private Const cGrip As Integer = 16
Private Const cCaption As Integer = 32
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim rc As Rectangle = New Rectangle(Me.ClientSize.Width - cGrip, Me.ClientSize.Height - cGrip, cGrip, cGrip)
ControlPaint.DrawSizeGrip(e.Graphics, Me.BackColor, rc)
rc = New Rectangle(0, 0, Me.ClientSize.Width, cCaption)
e.Graphics.FillRectangle(Brushes.DarkBlue, rc)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &H84 Then
Dim pos As Point = New Point(m.LParam.ToInt32())
pos = Me.PointToClient(pos)
If pos.Y < cCaption Then
m.Result = CType(2, IntPtr)
Return
End If
If pos.X >= Me.ClientSize.Width - cGrip AndAlso pos.Y >= Me.ClientSize.Height - cGrip Then
m.Result = CType(17, IntPtr)
Return
End If
End If
MyBase.WndProc(m)
End Sub
End Class
the problem is that if I should add a control like Panel
and dock it to the top, it stays on top of the Blue rectangle that was painted.
I want every docking to start below the painted rectangle