Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ResizeSeup()
End Sub
#Region " Resize "
Private Sub ResizeSeup()
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
AddHandler Me.MouseMove, AddressOf ControlMouseMoving
Dim LabelLeftWidth As New Label
Dim LabelTopHeight As New Label
Dim LabelRightWidth As New Label
Dim LabelBottomHeight As New Label
Dim LabelRightBottom As New Label
Dim LabelLeftBottom As New Label
Dim LabelRightTop As New Label
Dim LabelLeftTop As New Label
LabelLeftWidth.Dock = DockStyle.Left
LabelTopHeight.Dock = DockStyle.Top
LabelRightWidth.Dock = DockStyle.Right
LabelBottomHeight.Dock = DockStyle.Bottom
LabelRightBottom.Anchor = AnchorStyles.Right Or AnchorStyles.Bottom
LabelLeftBottom.Anchor = AnchorStyles.Left Or AnchorStyles.Bottom
LabelRightTop.Anchor = AnchorStyles.Right Or AnchorStyles.Top
LabelLeftTop.Anchor = AnchorStyles.Left Or AnchorStyles.Top
LabelLeftWidth.Width = 6
LabelTopHeight.Height = 6
LabelRightWidth.Width = 6
LabelBottomHeight.Height = 6
LabelRightBottom.Size = New Size(6, 6)
LabelLeftBottom.Size = New Size(6, 6)
LabelRightTop.Size = New Size(6, 6)
LabelLeftTop.Size = New Size(6, 6)
LabelRightBottom.Location = New Point(Me.Width - LabelRightBottom.Width, Me.Height - LabelRightBottom.Height)
LabelLeftBottom.Location = New Point(0, Me.Height - LabelLeftBottom.Height)
LabelRightTop.Location = New Point(Me.Width - LabelRightTop.Width, 0)
LabelLeftTop.Location = New Point(0, 0)
LabelLeftWidth.Cursor = Cursors.SizeWE
LabelTopHeight.Cursor = Cursors.SizeNS
LabelRightWidth.Cursor = Cursors.SizeWE
LabelBottomHeight.Cursor = Cursors.SizeNS
LabelRightBottom.Cursor = Cursors.SizeNWSE
LabelLeftBottom.Cursor = Cursors.SizeNESW
LabelRightTop.Cursor = Cursors.SizeNESW
LabelLeftTop.Cursor = Cursors.SizeNWSE
AddHandler LabelLeftWidth.MouseMove, AddressOf LabelLeftWidth_MouseMove
AddHandler LabelTopHeight.MouseMove, AddressOf LabelTopHeight_MouseMove
AddHandler LabelRightWidth.MouseMove, AddressOf LabelRightWidth_MouseMove
AddHandler LabelBottomHeight.MouseMove, AddressOf LabelBottomHeight_MouseMove
AddHandler LabelRightBottom.MouseMove, AddressOf LabelRightBottom_MouseMove
AddHandler LabelLeftBottom.MouseMove, AddressOf LabelLeftBottom_MouseMove
AddHandler LabelRightTop.MouseMove, AddressOf LabelRightTop_MouseMove
AddHandler LabelLeftTop.MouseMove, AddressOf LabelLeftTop_MouseMove
Me.Controls.Add(LabelLeftWidth)
Me.Controls.Add(LabelTopHeight)
Me.Controls.Add(LabelRightWidth)
Me.Controls.Add(LabelBottomHeight)
Me.Controls.Add(LabelRightBottom)
Me.Controls.Add(LabelLeftBottom)
Me.Controls.Add(LabelRightTop)
Me.Controls.Add(LabelLeftTop)
LabelRightBottom.SendToBack()
LabelLeftBottom.SendToBack()
LabelRightTop.SendToBack()
LabelLeftTop.SendToBack()
LabelLeftWidth.SendToBack()
LabelTopHeight.SendToBack()
LabelRightWidth.SendToBack()
LabelBottomHeight.SendToBack()
End Sub
Private Sub ControlMouseMoving(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx, yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
sender.Location = New Point(sender.Location.X + e.X - xx, sender.Location.Y + e.Y - yy)
Else
xx = e.X : yy = e.Y
End If
End Sub
Private Sub LabelRightWidth_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Width = Me.Width + e.X - xx
Else
xx = e.X
End If
End Sub
Private Sub LabelBottomHeight_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Height = Me.Height + e.Y - yy
Else
yy = e.Y
End If
End Sub
Private Sub LabelLeftWidth_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Left = Me.Left + e.X - xx
Me.Width = Me.Width - e.X + xx
Else
xx = e.X
End If
End Sub
Private Sub LabelTopHeight_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Top = Me.Top + e.Y - yy
Me.Height = Me.Height - e.Y + yy
Else
yy = e.Y
End If
End Sub
Private Sub LabelRightBottom_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx, yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Width = Me.Width + e.X - xx
Me.Height = Me.Height + e.Y - yy
Else
xx = e.X
yy = e.Y
End If
End Sub
Private Sub LabelLeftBottom_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx, yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Left = Me.Left + e.X - xx
Me.Width = Me.Width - e.X + xx
Me.Height = Me.Height + e.Y - yy
Else
xx = e.X
yy = e.Y
End If
End Sub
Private Sub LabelRightTop_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx, yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Width = Me.Width + e.X - xx
Me.Top = Me.Top + e.Y - yy
Me.Height = Me.Height - e.Y + yy
Else
xx = e.X
yy = e.Y
End If
End Sub
Private Sub LabelLeftTop_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Static xx, yy As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
Me.Left = Me.Left + e.X - xx
Me.Width = Me.Width - e.X + xx
Me.Top = Me.Top + e.Y - yy
Me.Height = Me.Height - e.Y + yy
Else
xx = e.X
yy = e.Y
End If
End Sub
#End Region
End Class