Solved

Drag and Drop VB --> Another Application

Posted on 2000-03-07
8
285 Views
Last Modified: 2012-05-04
Hi, I am trying to set up my VB program to enable drag and drop to another application.  More specifically, I have in my VB program both a listbox and a treeview each of which have a list of files in them, with full paths.  I want to enable the user to drag one of these files to a program (in this case winamp) to allow them to play, or be added to the playlist, etc.  

Please keep in mind that I have no knowledge of drag and drop or how it works.  If you are going to suggest something, please include code for it.  In so far as I am asking for such a thurough description, I have set the point value accordingly high.  Thanks.  
0
Comment
Question by:musaka
8 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 2592583
I tried this, but it doesn't work. It is possible to accept files from other applications (e.g. from Explorer), but the opposite does not work. I think it's a bug.
0
 

Author Comment

by:musaka
ID: 2592626
Are you saying it cannot be done?  
0
 
LVL 15

Expert Comment

by:ameba
ID: 2592672
No, I am saying I cannot do it, see my question http://www.experts-exchange.com/Q_10294456.html
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 14

Expert Comment

by:wsh2
ID: 2593189
If Winamp is the program you desire to port to.. the real quick solution would be to a Shell command..

dim strWinAmp as String
dim strMP3File as String
strWinAmp = "c:\pathname\WINAMP.EXE"
strMP3File = "c:\pathname\MY.MP3"
SHELL strWinAmp & " " & strMP3File


0
 
LVL 1

Accepted Solution

by:
Catouch earned 300 total points
ID: 2595362
I wrote something in the opposite direction --> drag something from e.g. explorer to a listbox in VB, maybe it can help you.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Purpose: To drag xls sheets from outside the manager into it. e.g.:             '
'         drag from the explorer into manager                                    '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub treeview_OLEDragDrop(Data As MSComCtlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim sMsg As String, i%

    For i% = 1 To Data.Files.Count
        sMsg = sMsg & vbLf & Data.Files(i%)
    Next i%
   
   

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Purpose: To drag xls sheets from outside the manager into it. e.g.:             '
'         drag from the explorer into manager                                    '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub treeview_OLEDragOver(Data As MSComCtlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
    WksTree.DropHighlight = WksTree.HitTest(X, Y)
End Sub
0
 

Author Comment

by:musaka
ID: 2606822
Adjusted points to 300
0
 

Author Comment

by:musaka
ID: 2606823
As for teh comment regarding shell, I want to enable drag&drop so you could use any mp3 player you wish...not jus winamp...it was just an example

As for the code going in reverse...I've seen similar but I'm still not sure how the reverse is implemented.  Thanks though.


I'm gonna try to up the point to lure an answer...
0
 

Author Comment

by:musaka
ID: 2606882
Ok...actually your reverse code gave me an idea...and now since this is the topic of controversy...i'll post the code I got ot work so you can all use it

for a given listbox...I set OLEdragmode to automatic...and then implemented the following code

Private Sub List1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    Data.Files.Clear
    Data.SetData , vbCFFiles
    Data.Files.add filename
End Sub


and it works...!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 61
Excel VBA, find a string in a column, update a cell 7 77
Add a task in Outlook from access 11 39
Exit a vb6 apps when a calling it apps closes 15 46
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

786 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