Solved

drag and drop part II

Posted on 2006-07-08
23
240 Views
Last Modified: 2013-02-27
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.
0
Comment
Question by:lpetrowicz
  • 12
  • 8
  • 3
23 Comments
 
LVL 9

Expert Comment

by:justchat_1
ID: 17065248
What code are you using to drag and drop the picture?
0
 

Author Comment

by:lpetrowicz
ID: 17065317
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.
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17065372
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?
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17065444
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...
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17065715
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
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17065717
To test it just drag the icons on to the form...
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 17066656
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
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17066668
^ that doesnt allow the pictures to stay on the forms ^
0
 
LVL 16

Assisted Solution

by:burakiewicz
burakiewicz earned 400 total points
ID: 17066678
the pictures never move or leave the form
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17066714
can you expand on your comment-what was that in response to?
0
 

Author Comment

by:lpetrowicz
ID: 17070094
burakiewicz,

I need a little more clearer explanation please.  Your info sounds great just a little confrusing.  New to it all.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 9

Expert Comment

by:justchat_1
ID: 17070128
Did you have a chance to look at the link I posted?
0
 

Author Comment

by:lpetrowicz
ID: 17070177
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.
0
 

Author Comment

by:lpetrowicz
ID: 17070215
does anyone have an example  drag and drop program they could send to me as an example to look at?
0
 
LVL 9

Accepted Solution

by:
justchat_1 earned 100 total points
ID: 17070247
The program is exactly what you are trying to make not just the drag and drop the whole placing images...

You need to download and register this dll also (I guessed you missed the comment):
http://www.vbaccelerator.com/home/vb/Code/Controls/ImageList/vbAccelerator_Image_List_Control/VB6_ImageList_Control_Binary.zip

Once you have that working make the code corrections I posted and it will work exactly the way you described in drag & drop part I
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 17070722
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
0
 

Author Comment

by:lpetrowicz
ID: 17073830
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.
0
 

Author Comment

by:lpetrowicz
ID: 17073897
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.
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17075556
You need to paint the main picture onto the form... Pictures boxes will get painted over
0
 

Author Comment

by:lpetrowicz
ID: 17077935
paint the picture on??????
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17078047
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...
0
 

Author Comment

by:lpetrowicz
ID: 17094888
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!!!!)??
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17095910
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
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now