Set form position to mouse coordinates?

Posts 1–14 of 14 · Page 1 of 1
Set form position to mouse coordinates?
I would like to know how to set the form position to the coordinates of the cursor. Any help will be appreciated.
Add this to form1.load :

Code:
Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)
Then add this code to set the cursor postition!
Code:
 Cursor.Position = New Point(CORDNIANTES HERE, CORDNIANTES HERE)
if your question is how move borderless form -->

under Public class *(form name) put this:
Dim Aloc As New Point(0, 0)
Dim Acur As New Point(0, 0)
after put this:
Private Sub Definitions()
Aloc = Location
Acur = Cursor.Position
End Sub
then add timer and put this in:
Location = Aloc - Acur + Cursor.Position
choose what you need to click to move the form (Picturebox for exemple)
click on picturebox -> events -> MouseDown
add in:
*(timer name).Enabled = True
*(timer name.Start()
Definitions()
now go picturebox -> events - > MouseUp
add in:
*(timer name).Stop()
Definitions()
now you can click on the picturebox and move your mouse to move the form

Lol? He said "Mouse Coordinates". Thanks guys. I needed to know this and was gonna post soon, but oh well. One thing. How do i find the coordinates and if it was for CA, would each size of game be different?
Here is exactly what I want:
I want to be able to move my cursor, and have the form follow it, so that wherever I move my cursor, the form would be, so that the cursor is always in the middle of the form.
oh. I didnt read it properly. I just guesses u wanted the same thing as me xD Cant help u, soz.
I´ll try.....Need some time!
i know

how to know the mouse coordinations
Code:
        Dim cx As Integer = Cursor.Position.X
        Dim cy As Integer = Cursor.Position.Y
then made a timer

Code:
*timer
        Dim cx As Integer = Cursor.Position.X
        Dim cy As Integer = Cursor.Position.Y

Me.Location = New Point(cx, cy)
didn't try this

but i think this works :P
Well, I got it, but the problem is is that the mouse is in the top-left corner of the form. Is it possible to put it in the middle?
I made it .
Make a timer
Add this code:
Code:
 Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)

        Me.Location = Cursor.Position
Please THANK ME
Quote Originally Posted by Zoom View Post
I made it .
Make a timer
Add this code:
Code:
 Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)

        Me.Location = Cursor.Position
Please THANK ME
can to
Nvm I got it. /close
Quote Originally Posted by Lolland View Post
Nvm I got it. /close
Double post >.<
Well
Code:
{
    POINT mPos;
    GetCursorPos(&mPos);
    float x = mPos.x;
    float y = mPos.y;
    cout << "X: " << x << " " << "Y: " << y << endl;
}
This can be used to get the coordinates
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us