[help]How could my drag code be smoother?

Posts 1–6 of 6 · Page 1 of 1
[help]How could my drag code be smoother?
ok this is my full drag code

Code:
 Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown
        Xpos = Cursor.Position.X - Button2.Location.X
        Ypos = Cursor.Position.Y - Button2.Location.Y
    End Sub

    Private Sub Button2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Pos = MousePosition
            Pos.X = Pos.X - Xpos
            Pos.Y = Pos.Y - Ypos
            Button2.Location = Pos
            My.Settings.ff = Button2.Location
            My.Settings.Save()
        End If
    End Sub
how would i make it smoother? as in dragging wise less laggy i was think on making it save only when u let go but rember it's a button i dont want it to save every time i click it. only when i'm done dragging.
Why do you drag button 2?

You could just do
Code:
me.position = xpos & "," & ypos
Oh I get it, button 2 is your Drag Button.

You can do the same but better in the form1_mousedown event. Which means you don't need that button there.
Quote Originally Posted by SPittn_Blood View Post
Why do you drag button 2?

You could just do
Code:
me.position = xpos & "," & ypos
Oh I get it, button 2 is your Drag Button.

You can do the same but better in the form1_mousedown event. Which means you don't need that button there.



Me.location = new point(x,y)
because it's part of the desktop im coding, this would be a shortcut, so i want it to drag so it looks good if i remove the whole saving it dont lagg at all.
how about you save everything when the program closes?

and put some text saying "Saving Settings..Shutting Down"
thanks and no thats not what button2 does it actually moves it's slef when i click down and drag
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us