Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

top / Left to X Y cordinates

Status
Not open for further replies.

Antithott

IS-IT--Management
Jan 20, 2006
90
DK
Hi,

Im trying to make a picture box move with the mouse on mousedown event. Im getting the mouse X and Y cordinates then i wanna pass those on to the picture box, and have a timer update mouse XY to picture XY. the problem is that i cant find a way to modify the XY of the picture box, i can only do it by changing top and left etc, but those cordinates dont match the mouse XY so the picture box moves kinda randomly.

So in the end, im asking if anyone could show me a way to change the picture XY instead of useing top / left.. or a way to get top / left to match the mouse XY.

- anti
 
see thread796-1152284 might be helpful.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Why not just set the picture box's top and left properties to equal the from.MousePosition.X and frm.MousePosition.Y?

Or if you need it to offset (so that clicking in the middle of the picture box doesn't make it jump), On mouse down get the picturebox.mouseposition.x and .y and subtrack those values from the form.mouseposition.x and .y and set the picturebox.top and .left to that value.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
In addition to Rick's suggestions, I would drop the timer event, and set a boolean flag variable. Set it to true in the MouseDown event, and then in the Form's MouseMove event check the flag, and set the picturebox's location to the mouse's location. Set the flag back to false in the MouseUp Event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top