How to change cursor position to a picturebox location in VB
i think the title is pretty clear but i'll try to get more into it.
so i created a game where you use the mouse to play, it's like the game labirynth. you can't touch the walls or you lose.
when i start the level i want the cursor to appear in it's starting position, which is a red picturebox, but i dont know how to...
here is the code i used:
Windows.Forms.Cursor.Position = New Point(679, 650)
as you can see there is a massive problem about this code.
the location where the cursor appears is actuallt dependent of the resolution of the screen开发者_C百科.
for example: with my monitor resolution, the location (679, 650) is right on top of the picturebox i need it to appear on. but if you have a different resolution on your monitor it will appear on a different place...
i need to actually make it appear on top of the picturebox.
i wish i could be clearer than this :(
you can set your mouse location after taking the value of your picture position.
x=picture1.left
y=picture1.top
Windows.Forms.Cursor.Position = New Point(x+somevalue,y+somevalue)
精彩评论