We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,996 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Moving Form Without Control Box

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

2
Contributors
2
Replies
1 Day
Discussion Span
3 Months Ago
Last Updated
3
Views
t2nator
Newbie Poster
20 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

is form1 the child form?

tinstaafl
Nearly a Posting Virtuoso
1,326 posts since Jun 2010
Reputation Points: 355
Solved Threads: 230
Skill Endorsements: 14

yes

t2nator
Newbie Poster
20 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0621 seconds using 2.66MB