Link to home
Start Free TrialLog in
Avatar of lpetrowicz
lpetrowicz

asked on

drag and drop part II

I have learned how to drag and drop a picture to a form from a directory.  I am trying to find out how to drag and drop one smaller picture onto a larger picture on the same form.  Also, I want to be able to drag and drop this smaller picture several times.  Any ideas.
Avatar of justchat_1
justchat_1

What code are you using to drag and drop the picture?
Avatar of lpetrowicz

ASKER

well, I found a file online and what it did was allow you to paste to a form from a file directory.  I want to be able to have a picture of a car on a form and then have a set of graphics that I can choose from on the same form and then drag and drop them onto the car and be able to use the same graphic again if I wanted to.  I don't actually have any code yet for that.
I helped you with the last question... if you needed code all you had to do was post back there:

So let me make sure I understand what you need:
1. drag pictures from a toolbar to a form
2. drag pictures from a directory onto the form
3. be able to move those pictures around on a form

...did I miss anything?
As far as dragging and dropping onto a form, this is probably what you had in mind:
http://www.vbaccelerator.com/home/vb/Code/Controls/ImageList/Custom_Drag-Drop_Images_Using_ImageLists/article.asp
(note you will need to download and register vbalIml6.ocx)

That only drag and drops the pictures as text, im working on the code to make that images... until then check out that link and let me know if thats closer to what you wanted...
Ok using that code make the following changes:

1. remove the text box from the form
2. set the oledropmode property of the form to manual
3.  replace the old methods with these updated methods;

Private Sub picDragDrop_OLECompleteDrag(Effect As Long)
   '
   'm_cDrag.CompleteDrag
   '
End Sub

Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim pic As StdPicture
Set pic = ilsIcons.ItemPicture(Data.GetData(vbCFText) + 1)
m_cDrag.CompleteDrag
frmImageListDragDrop.PaintPicture pic, X, Y, pic.Width, pic.Height
End Sub
To test it just drag the icons on to the form...
put 2 different images on the form:image1,image2

make image1 an control array and add your pictures to the images
on the image1_mousedown  put
image1(index).drag

on image 2 set
image2_dragdrop()

image2.picture=source.picture
^ that doesnt allow the pictures to stay on the forms ^
SOLUTION
Avatar of burakiewicz
burakiewicz
Flag of United States of America 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
can you expand on your comment-what was that in response to?
burakiewicz,

I need a little more clearer explanation please.  Your info sounds great just a little confrusing.  New to it all.
Did you have a chance to look at the link I posted?
I did and I downloaded the file and the file didn't work.  I was going to see what the code looked like on it to help guide me.  Throught the use of my two books, I have been able to understand a few things but this drag and drop thing is crazy.
does anyone have an example  drag and drop program they could send to me as an example to look at?
ASKER CERTIFIED SOLUTION
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
start a new project

add to images to the form


image1 make a ontrol array like
image1(0)
image1(1) and so on

image2 make the big picture
copy this

Private Sub Image2_DragDrop(Source As Control, X As Single, Y As Single)
Image2.Picture = Source.Picture
End Sub


and this

Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1(Index).Drag
End Sub
burakiewicz,

I did exactly as you had written.  The control array did drag and drop and it stayed so I could use it again as well.  There was only one problem.  When I dragged and dropped it on the main picture, the main picture disappeared.
justchat 1,

I did finally get your idea to work and thank you.  The only problem with that is that there is no main picture to drag it to and it doesn't quite get placed where I would like it to.
You need to paint the main picture onto the form... Pictures boxes will get painted over
paint the picture on??????
notice this code (in my list of corrections):
frmImageListDragDrop.PaintPicture pic, X, Y, pic.Width, pic.Height

This paints the icon onto the form...If you want a background picture (unless I misunderstood the question-which is likely) then you will need to paint the background picture on the form or use the picture property to set it as the forms background...
justchat 1,

Ok, I feel like an idiot but I am still confused.  Here is clearly what I am looking for.  I have the picture of a car (car.jpg).  I want this picture to be on Form1 and add a couple of graphic pictures (graphic1.jpg, graphic2.jpg) to be able to drag and drop on that car picture.  I also want to be able to drag and drop the same graphic picture numerous times if I would like.  Please, what exactly should my code look like (EXACTLY!!!!, PLEASE!!!!)??
move a graphic onto the form and then move it around? or just move multiple of the same graphics around on the form?

if you want to add images to car.jpg I would suggest starting with setting your forms .picture property to car1.jpg