Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag and Drop file opens program with droped file loaded? 1

Status
Not open for further replies.

Skorkpup

Programmer
Feb 17, 2005
11
Hi Guys I wonder if any one can help me.

I am making a simple program with an OLE control set to wave files. I would like to be able to drag and drop a file into the programs icon and have the file loaded and playing in the OLE control when the progran opens. I would also like the wave to begin playing when the wave file is dropped into the OLE container after the program opens automatically. I tried this by placing OLE1.DoVerb 0 into the sub, OLE1_DragDrop but to no avail it will not play after dropped.

So far I can drag the file into the ole control after the program is already open the sound plays through the sub Ole1_MouseMove and the sound stops with a Command button.

Any and all help would be greatly appriciated.
Thanks,
Skorkpup

Here is my code so far:

Option Explicit

Private Sub Command1_Click()
'stop the sound
OLE1.Action = 9
End Sub

Private Sub Command2_Click()
'close the program
Unload Me
End Sub

Private Sub OLE1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'play the sound
OLE1.DoVerb 0
End Sub


Skorkpup
 
If I understand correctly, you want an icon on your desktop. When you drag a file on top of this icon, you want your app to open and start playing this file.

If I understand correctly, then you need to make your app accept command line arguments. When you drop a file on top of the icon, the filename will be inserted as a command line argument.

To test this... create a new VB Project. Add this code:

Code:
Option Explicit

Private Sub Form_Load()
    
    If VBA.Command$ <> "" Then
        MsgBox VBA.Command$
    End If
    
End Sub

Compile this project and add a shortcut to it on your deskptop. Now, when you drop a file on to it, the filename will pop up in a message box.

From there, you need to make sure it is a sound file and if it is, cause it to play.

Hope this helps.


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top