Doesn't work, mine's better.
Code
Private resizeFlag As Boolean = False
Private mouseDownLocation As Point
Private resizeNStop As Boolean = False
Private resizeNSbottom As Boolean = False
Private resizeWEleft As Boolean = False
Private resizeWEright As Boolean = False
Private FormPanel As New Panel
Code
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
AddHandler Me.MouseMove, AddressOf myMouseMove
AddHandler Me.MouseUp, AddressOf myMouseUp
AddHandler Me.MouseDown, AddressOf myMouseDown
FormPanel.BorderStyle = BorderStyle.FixedSingle
FormPanel.Dock = DockStyle.Fill
AddHandler FormPanel.MouseDown, AddressOf myMouseDown
AddHandler FormPanel.MouseUp, AddressOf myMouseUp
AddHandler FormPanel.MouseMove, AddressOf myMouseMove
Me.Controls.Add(FormPanel)
Dim statusBar As New StatusBar
statusBar.Dock = DockStyle.Bottom
AddHandler statusBar.MouseDown, AddressOf myMouseDown
AddHandler statusBar.MouseUp, AddressOf myMouseUp
AddHandler statusBar.MouseMove, AddressOf myMouseMove
FormPanel.Controls.Add(statusBar)
Dim lblTitle As New Label
lblTitle.Text = "Form1"
lblTitle.TextAlign = ContentAlignment.MiddleCenter
lblTitle.AutoSize = False
lblTitle.Dock = DockStyle.Top
AddHandler lblTitle.MouseDown, AddressOf myMouseDown
AddHandler lblTitle.MouseUp, AddressOf myMouseUp
AddHandler lblTitle.MouseMove, AddressOf myMouseMove
FormPanel.Controls.Add(lblTitle)
Code
Private Sub myMouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If (e.Button = Windows.Forms.MouseButtons.Left) Then
If Not resizeFlag Then
Me.Location += e.Location - mouseDownLocation
Else
If resizeNSbottom Then
If (CType(sender, Control).Dock = DockStyle.None) Or (CType(sender, Control).Dock = DockStyle.Fill) Then
Me.Height = e.Y
Else
Me.Height += e.Y - mouseDownLocation.Y
End If
End If
If resizeNStop Then
Dim previousTop As Integer = Me.Top
Me.Top += e.Y - mouseDownLocation.Y
Me.Height += previousTop - Me.Top
End If
If resizeWEright Then
Me.Width = e.X
End If
If resizeWEleft Then
Dim previousLeft As Integer = Me.Left
Me.Left += e.X - mouseDownLocation.X
Me.Width += previousLeft - Me.Left
End If
End If
Else
setCursor()
End If
End Sub
Private Sub myMouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Left Then
If (resizeFlag = False) Then
If checkResize() Then
resizeFlag = True
End If
setCursor()
End If
mouseDownLocation = e.Location
End If
End Sub
Private Sub myMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
resizeFlag = False
resizeNSbottom = False
resizeNStop = False
resizeWEright = False
resizeWEleft = False
End Sub
Private Sub setCursor()
Cursor = Cursors.Default
If (Cursor.Position.X >= Me.Left + Me.Width - 10) Then
Cursor = Cursors.SizeWE
End If
If (Cursor.Position.X <= Me.Left + 10) And (Cursor.Position.X >= Me.Left) Then
Cursor = Cursors.SizeWE
End If
If (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 10) Then
Cursor = Cursors.SizeNS
End If
If (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 10) Then
Cursor = Cursors.SizeNS
End If
If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
Cursor = Cursors.SizeNESW
End If
If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
Cursor = Cursors.SizeNWSE
End If
If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
Cursor = Cursors.SizeNESW
End If
If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
Cursor = Cursors.SizeNWSE
End If
End Sub
Private Function checkResize() As Boolean
Cursor = Cursors.Cross
If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
resizeWEright = True
resizeNStop = True
Return True
End If
If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
resizeWEright = True
resizeNSbottom = True
Return True
End If
If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
resizeWEleft = True
resizeNSbottom = True
Return True
End If
If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
resizeWEleft = True
resizeNStop = True
Return True
End If
If (Cursor.Position.X >= Me.Left + Me.Width - 10) Then
resizeWEright = True
Return True
End If
If (Cursor.Position.X <= Me.Left + 10) And (Cursor.Position.X >= Me.Left) Then
resizeWEleft = True
Return True
End If
If (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 10) Then
resizeNStop = True
Return True
End If
If (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 10) Then
resizeNSbottom = True
Return True
End If
Return False
End Function
I wonder what you will complain about.