Just prevent the left and top values from being edited like in this example. Only the ratio's need some adjusting, but you should be able to figure that out.
Namespace WindowsFormsApplication2
Public Partial Class Form1
Inherits Form
Const MAXIMUM As Integer = 800
Private left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0, deltaResize As Integer = 0
Private startResize As Boolean = False
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_ResizeEnd(sender As Object, e As EventArgs)
If Form1.ActiveForm.Left <> left Then
Form1.ActiveForm.Left = left
End If
If Form1.ActiveForm.Top <> top Then
Form1.ActiveForm.Top = top
End If
If Form1.ActiveForm.Width > MAXIMUM Then
Form1.ActiveForm.Width = MAXIMUM
End If
Dim formResize As Integer = width - Form1.ActiveForm.Width
Dim ratioFormBar As Single = MAXIMUM / progressBar1.Width
Try
progressBar1.Value = progressBar1.Value - CInt(Math.Floor(formResize / ratioFormBar))
Catch
If progressBar1.Value - CInt(Math.Floor(formResize / ratioFormBar)) < 0 Then
progressBar1.Value = 0
End If
If progressBar1.Value - CInt(Math.Floor(formResize / ratioFormBar)) > MAXIMUM Then
progressBar1.Value = MAXIMUM
End If
End Try
End Sub
Private Sub Form1_ResizeBegin(sender As Object, e As EventArgs)
If Form1.ActiveForm IsNot Nothing Then
left = Form1.ActiveForm.Left
top = Form1.ActiveForm.Top
width = Form1.ActiveForm.Width
height = Form1.ActiveForm.Height
End If
End Sub
Private Sub Form1_Activated(sender As Object, e As EventArgs)
progressBar1.Value = Form1.ActiveForm.Left
progressBar1.Maximum = MAXIMUM
width = Form1.ActiveForm.Width
height = Form1.ActiveForm.Height
End Sub
Private Sub progressBar1_MouseDown(sender As Object, e As MouseEventArgs)
If e.Button = MouseButtons.Left Then
deltaResize = e.X
startResize = True
End If
End Sub
Private Sub progressBar1_MouseUp(sender As Object, e As MouseEventArgs)
If e.Button = MouseButtons.Left AndAlso startResize Then
Dim mouseMovement As Integer = e.X - deltaResize
Dim ratioFormBar As Single = MAXIMUM / progressBar1.Width
Form1.ActiveForm.Width = Form1.ActiveForm.Width + CInt(Math.Floor(mouseMovement * ratioFormBar))
startResize = True
End If
End Sub
End Class
End Namespace