Я пытаюсь создать форму без полей с помощью этого кода
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
проблема в том, что если я добавлю элемент управления вроде Panel
и закреплю его наверху, он останется поверх синего прямоугольник, который был нарисован. Я хочу, чтобы каждая стыковка начиналась под нарисованным прямоугольником