?
Solved

Drag and drop onto an applications icon/shortcut

Posted on 2005-04-28
9
Medium Priority
?
455 Views
Last Modified: 2008-02-26
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.
0
Comment
Question by:Metallicraft
  • 4
  • 4
9 Comments
 

Author Comment

by:Metallicraft
ID: 13888952
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.
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13892011
>>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 ...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Metallicraft
ID: 13893485
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.
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13893723
hi
>>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


0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 13894079
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
    Else
        MsgBox fileName, vbExclamation, "Invalid File or Folder"
    End If
End Sub
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13894711
hi
thats great,
i tried it, and worked. its really a nice information
Thank u Idle_Mind

;-)
Shiju
0
 

Author Comment

by:Metallicraft
ID: 13894916
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?
0
 

Author Comment

by:Metallicraft
ID: 13896624
Nvmd, I got it working.  Thank you for your help.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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 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…
Suggested Courses

807 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