Link to home
Start Free TrialLog in
Avatar of mi5
mi5

asked on

Dragging and Dropping

How can I drop an item onto a form when the user has dragged it. For a control such as a picture, I use picture1.drag to make the shadow of the box follow the mouse. I want to make the object stay where the user clicks the mouse. I have tried using picture1.left = X and picture1.top = Y (where X and Y are the mouse pointer coordinates), but the object will move because the X and Y coordinates are never in the same place as where the x and y coordinates of the box are measured. Is there an easy command to drop the object?
Avatar of phiro
phiro

How do you mean never the same?
Does the box seem to jump when you drop it? Or does the box appear at random somewhere on the form?
The mouse uses screen coordinaties wheras the Picture.left and top use their coordinates relative to the Form coordinates. So you would have to correct by putting:
picture1.Top = mouse.y - (form.Top -1 ) and Picture1.Left = mouse.x - (form.Left -1) (Look whether the -1 is needed in your case... )
Delete this question, you've posted it twice!

phiro - see
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10177535 
See what you mean. Thanx carag_g.
ASKER CERTIFIED SOLUTION
Avatar of VBGuru
VBGuru
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial