Hello all.
I am making a virtual iPod touch in VB.NET, and I hate it how I have a form that I can't drag and move the form around the screen, I've trying making the form goto Mouse's location when the mouse moves and Dragging = True, but that doesn't work and makes the form flicker around at the speed of light. :(
Thanks, can anyone help me please? :)


In order to avoid the flickering, use the SetStyle method of the form.

    Public Sub EnableDoubleBuffering()
       ' Set the value of the double-buffering style bits to true.
       Me.SetStyle(ControlStyles.DoubleBuffer _
         Or ControlStyles.UserPaint _
         Or ControlStyles.AllPaintingInWmPaint, _
    End Sub

Edited 4 Years Ago by pyTony: fencing ~~~ vb code tags added

Place this code in the Form's mouse down event.

'On mousedown'
If e.Button = Windows.Forms.MouseButton.Left Then

Capture = True

End If

Place this in the mouse up event.

'On mouseup'
Capture = False

Next place this in the timer's tick event.

'Place this code in a timer.'
'Set tic to 15 milliseconds.'

dim i as integer = 0

i+= 1

If i > 15 Then
Me.location = new Point (MousePosition.x - (me.width /2 ),Mouseposition.y - (me.height /2))
End If

Now, after the user holds the mouse for 15 milliseconds, it will start to relocate.

Edited 4 Years Ago by Begginnerdev: edit

This question has already been answered. Start a new discussion instead.