Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Drag and Drop VB --> Another Application

Posted on 2000-03-07
8
289 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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