1,105,310 Community Members

Moving Form Without Control Box

Member Avatar
t2nator
Newbie Poster
22 posts since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
tinstaafl
Postaholic
2,009 posts since Jun 2010
Reputation Points: 559 [?]
Q&As Helped to Solve: 400 [?]
Skill Endorsements: 35 [?]
 
0
 

is form1 the child form?

Member Avatar
t2nator
Newbie Poster
22 posts since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

yes

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: