0

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? :)

mitchfizz05.

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Begginnerdev
0

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, _
         True)
       Me.UpdateStyles()
    End Sub

Edited by pyTony: fencing ~~~ vb code tags added

0

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

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

Capture = True
relocateTimer.Start()

End If

Place this in the mouse up event.

'On mouseup'
relocateTimer.Stop
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 by Begginnerdev: edit

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.