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?
Who is Participating?
VBGuruConnect With a Mentor Commented:
use dragicon property
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
See what you mean. Thanx carag_g.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.