Solved

Drag and Drop VB --> Another Application

Posted on 2000-03-07
8
297 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
[X]
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
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

724 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