Page 1 of 1

Moving cursor position

Posted: Tue Jul 24, 2012 2:05 am
by Bogoh67
So i want an image to follow the cursor and i mean directly behind it
But when i run the program the image is extremely off
current code im using
Code: Select all
 PictureBox1.Location = New Point(MousePosition.X, MousePosition.Y)
i have used
Code: Select all
 PictureBox1.Location = MousePosition
neither work
Please help

Re: Moving cursor position

Posted: Tue Jul 24, 2012 2:37 am
by M1z23R
You should use your form's move event, not picturebox's.
type under the public class Form1 : Protected overrides onmousemove - press enter
then add picturebox1.location=new point(e.x,e.y)

Re: Moving cursor position

Posted: Tue Jul 24, 2012 3:33 am
by Bogoh67
Doesn't work. Maybe i did it wrong but this is what happened
Code: Select all
 Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
        MyBase.OnMouseMove(e)
        PictureBox1.Location = New Point(MousePosition.X, MousePosition.Y)
    End Sub
I don't know if this changes anything, but here is my forms changed settings
Code: Select all
AutoScaleMode-Font
BackColor-WindowFrame
ForeColor-WindowFrame
FormBorderStyle-None
ShowInTaskbar-False
Size-ScreenSize
StartPosition-CenterScreen
Text-FullScreen
TopMost-True
TransparancyKey-WindowsFrame

Re: Moving cursor position

Posted: Tue Jul 24, 2012 7:51 am
by M1z23R
Do you want to move your form all over the screen, or picturebox inside the form ?

Re: Moving cursor position

Posted: Tue Jul 24, 2012 8:00 am
by Dummy1912
maybe with
Code: Select all
Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
        MyBase.OnMouseMove(e)
        PictureBox1.Location = New Point(e.Location.X, e.Location.Y)
    End Sub

Re: Moving cursor position

Posted: Tue Jul 24, 2012 9:51 am
by lolxot
hey
I'm currently @ school so I can't look up the code but I have made a game where this code is used: viewtopic.php?f=71&t=9468

Just download the source and search for the mousemove event

Re: Moving cursor position

Posted: Wed Jul 25, 2012 12:17 am
by Bogoh67
I actually fixed it myself. The reason why it was happening was because the start position of the form.