Dragging and dropping a .WAV from Delphi App to other apps

Is there an easy way to drag a .WAV file from a Delphi 2006 App to another 
app.     It's not from a listbox or anything like that.   It's from a custom 
window.  My code would need to be responsible for generating a .WAV file 
based on where the person initially clicked on a window.

Is the only way to drop a file from a Delphi 2006 to use complicated COM 
routines?   If so, then would the other app that receives the file need 
complicated com routines too, or would it work with any app that could 
accept a the same dropped file type from Explorer?


Thanks.
0
Jeff
8/28/2009 5:46:48 PM
embarcadero.delphi.win32 2183 articles. 0 followers. Follow

4 Replies
1439 Views

Similar Articles

[PageSpeed] 56

"Jeff Yankauer" <jeff2333@verizon.net> wrote in message 
news:155794@forums.codegear.com...

> Is there an easy way to drag a .WAV file from a Delphi 2006 App
> to another app.

Not an *easy* way, no.  You need to write two classes that implement the 
IDropSource and IDataObject interfaces (or use third-party classes, such as 
from Anders Melander's Drag-and-Drop suite, 
http://melander.dk/delphi/dragdrop), and then your code needs to call the 
Win32 API DoDragDrop() function when it detects that a drag&drop operation 
needs to take place.  The IDataObject object needs to contain information 
about the .WAV file and its contents.  Any app that implements the 
IDropTarget will then be able to accept the drag and extract the data as 
needed.

> Is the only way to drop a file from a Delphi 2006 to use complicated
> COM routines?

Yes.

> If so, then would the other app that receives the file need complicated
> com routines too

Yes.

> would it work with any app that could accept a the same dropped file type
> from Explorer?

Windows Explorer uses the same kind of COM routines for its own 
drag-and-drop operations.  IDropSource, IDropTarget, and IDataObject are the 
preferred way to drag/drop data around in Windows.

-- 
Remy Lebeau (TeamB)
0
Remy
8/28/2009 6:44:21 PM
Thanks for the reply.   I tried that toolkit and it works.  I'm wondering if 
you there might be a way to have my app drag and drop a file onto another 
app but render the file at the time the file is dropped rather than the file 
needing to already be written to disk at the full file size before 
initiating the drag and drop?

Thanks,

Jeff


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:155833@forums.codegear.com...
> "Jeff Yankauer" <jeff2333@verizon.net> wrote in message 
> news:155794@forums.codegear.com...
>
>> Is there an easy way to drag a .WAV file from a Delphi 2006 App
>> to another app.
>
> Not an *easy* way, no.  You need to write two classes that implement the 
> IDropSource and IDataObject interfaces (or use third-party classes, such 
> as from Anders Melander's Drag-and-Drop suite, 
> http://melander.dk/delphi/dragdrop), and then your code needs to call the 
> Win32 API DoDragDrop() function when it detects that a drag&drop operation 
> needs to take place.  The IDataObject object needs to contain information 
> about the .WAV file and its contents.  Any app that implements the 
> IDropTarget will then be able to accept the drag and extract the data as 
> needed.
>
>> Is the only way to drop a file from a Delphi 2006 to use complicated
>> COM routines?
>
> Yes.
>
>> If so, then would the other app that receives the file need complicated
>> com routines too
>
> Yes.
>
>> would it work with any app that could accept a the same dropped file type
>> from Explorer?
>
> Windows Explorer uses the same kind of COM routines for its own 
> drag-and-drop operations.  IDropSource, IDropTarget, and IDataObject are 
> the preferred way to drag/drop data around in Windows.
>
> -- 
> Remy Lebeau (TeamB)
0
Jeff
8/31/2009 5:05:41 PM
Jeff Yankauer schrieb:

> Thanks for the reply.   I tried that toolkit and it works.  I'm wondering if 
> you there might be a way to have my app drag and drop a file onto another 
> app but render the file at the time the file is dropped rather than the file 
> needing to already be written to disk at the full file size before 
> initiating the drag and drop?

You can try to use other than file references in OLE drag&drop. It only 
requires that both the sender and receiver can handle your object type.

DoDi
0
Hans
8/31/2009 5:42:39 PM
"Jeff Yankauer" <jeff2333@verizon.net> wrote in message 
news:156810@forums.codegear.com...

> Thanks for the reply.   I tried that toolkit and it works.  I'm wondering
> if you there might be a way to have my app drag and drop a file onto
> another app but render the file at the time the file is dropped rather
> than the file needing to already be written to disk at the full file size
> before initiating the drag and drop?

In general, the IDataObject that is passed around during the drag&drop 
operation needs to include CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR 
items, where the CFSTR_FILEDESCRIPTOR contains descriptive information about 
the file (filename, size, etc) and the CFSTR_FILECONTENTS contains an 
IStream or IStorage object that provides the actual file data.  That way, 
you can store your data anywhere you want (in memory, in a database, etc), 
and pull it out on an as-needed basis when the target of the drag&drop 
operation actually tries to read it.  Refer to MSDN for more details:

    Shell Clipboard Formats
    http://msdn.microsoft.com/en-us/library/bb776902.aspx

    Handling Shell Data Transfer Scenarios
    http://msdn.microsoft.com/en-us/library/bb776904.aspx

I don't know how to accomplish that with Ander's toolkit, though.  You would 
likely have to make use of the TFileGroupDescritorClipboardFormat and 
TFileContents...ClipboardFormat (such as 
TFileContentsStreamOnDemandClipboardFormat) classes, but I don't know how 
exactly.

-- 
Remy Lebeau (TeamB)
0
Remy
8/31/2009 6:18:49 PM
Reply: