Start New Discussion within our Software Development Community

How can the following code be change so the children form move event is smoother?

    Dim isMouseDown As Integer
    Dim MyX, MyY As Integer

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        isMouseDown = 1
        MyX = e.X : MyY = e.Y
        'Me.Cursor = Cursors.SizeAll
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If isMouseDown = 1 Then
            If e.X > MyX Then Me.Left = Me.Left + 1
            If e.X < MyX Then Me.Left = Me.Left - 1
            If e.Y > MyY Then Me.Top = Me.Top + 1
            If e.Y < MyY Then Me.Top = Me.Top - 1
        End If
    End Sub

    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        isMouseDown = 0
        Me.Cursor = Cursors.Default
    End Sub

THanks

This article has been dead for over six months. Start a new discussion instead.