Solved

Drag and Drop VB --> Another Application

Posted on 2000-03-07
8
279 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

17 Experts available now in Live!

Get 1:1 Help Now