Drag and drop onto an applications icon/shortcut

I have a vb6 application that allows the user to drop a folder onto it and it display the contents of the folder.  Is there a was to be able to drag the item onto the application desktop shortcut and have it execute?  I can drag an item on the shortcut, and the application fires, but the process that normally run when i drag something onto the form doesn't run.
Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
It works shijusn...at least it does on my WinXP Pro machine:

Option Explicit

Private Sub Form_Load()
    Dim cmd As String
    cmd = Trim(Command())
    If cmd <> "" Then
        Call processFile(cmd)
    End If
End Sub

Private Sub processFile(ByVal fileName As String)
    fileName = Replace(fileName, Chr(34), vbNullString)
    If Dir(fileName) <> "" Then
        MsgBox "Processing File: " & fileName
        ' do something with FILE filename in here
    ElseIf Dir(fileName, vbDirectory) <> "" Then
        MsgBox "Processing Folder: " & fileName
        ' do something with FOLDER filename in here
        MsgBox fileName, vbExclamation, "Invalid File or Folder"
    End If
End Sub
MetallicraftAuthor Commented:
Thanks for responding.  These show me how to drag and drop.  I can already do that.  I'm looking for a way to get the same functionality by dragging something onto a shortcut to the program.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Shiju SasidharanAssoc Project ManagerCommented:
>>something onto a shortcut to the program.
what does it mean ?
u want to drag a shortcut to ur program ?
or u want to create a shortcut from ur program
pls explain more ...
MetallicraftAuthor Commented:
I have a prgram that, when running, you can drag any folder on and it will tell you the folder's contents (it loads a listbox with file names).  I don't want the user to have to double-click my application and then have to drag a folder onto it.  I would rather just have a shortcut on the desktop (pointing to my application) and be able to drag a folder onto that shortcut.  Then my app would open and automatically start the processing.  Right now, I can drag a folder onto the shortcut of my application and it will open my application.  However, no processing begins...it's just as if I double-clicked the shortcut and still have to drag a folder onto the application's interface.
Shiju SasidharanAssoc Project ManagerCommented:
>>I can drag a folder onto the shortcut of my application and it will open my application.
its quite surprising !!!
its impossible i think ( i my memory is right)
dragging anything to a shorcut does nothing

Shiju SasidharanAssoc Project ManagerCommented:
thats great,
i tried it, and worked. its really a nice information
Thank u Idle_Mind

MetallicraftAuthor Commented:
That IS great.  It does appear to WANT to work.  I'm having an issue though.  Maybe while I've got you here, you can think about it?

Based on the description I gave above, when my app is open, I drag a folder onto a list box and I fill it with the names of the files in the folder.  This happens in the listbox's:

    Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)

procedure.  As you can see, the item coming in is of "DataObject" type.  Since I also want to process the Command() value, I moved the code that was residing in the List1_OLEDragDrop Sub into a separate ProcessDragNDrop Sub with one incoming variable: Data As DataObject.

Calling this from the List1_OLEDragDrop Sub works great.  However, when I try to call it from Form_Load with the Command() value, it doesn't want to work.  Is there a way to convert the incoming Command() value (which is a string) to the DataObject type so I can call the ProcessDragNDrop Sub?
MetallicraftAuthor Commented:
Nvmd, I got it working.  Thank you for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.