It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

How to make a form follow cursor smoothly?

Moderator: dafunkymunky

How to make a form follow cursor smoothly?

Postby mychael14 on Mon Oct 03, 2011 8:34 am

How to make a form follow cursor smoothly?

I'm new with this. Please help. :roll:
I want to make a form follow the cursor.
So every time I move the cursor the form will follow smoothly.

I have a code that I searched but it does not follow the cursor smoothly. :(

Code: Select all
Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove


        Me.Location = MousePosition


    End Sub

End Class
mychael14
 
Posts: 1
Joined: Mon Oct 03, 2011 8:17 am

Re: How to make a form follow cursor smoothly?

Postby sanjon on Thu Oct 20, 2011 1:17 pm

Add a timer and add the following code:
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Location = New System.Drawing.Point(MousePosition.X + 5, MousePosition.Y + 5)

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Timer1.Start()
    End Sub


Replace the +5 with the number of pixels you want the form to appear to the right and down of your cursor.
sanjon
 
Posts: 40
Joined: Sun Dec 05, 2010 6:20 pm


Who is online

Users browsing this forum: No registered users and 6 guests