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?
Delete this question, you've posted it twice!
phiro - see
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10177535
phiro - see
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10177535
See what you mean. Thanx carag_g.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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... )