I have been developing an app in VB.NET which requires a control object (for example, a ListViewItem) to be dragged out of the form, and to a user-specified location (for example, on the desktop, or in a folder).
However, The file that is intended to be 'copied', as the 'ListViewItem' represents, does not yet exist. It needs to be downloaded and then placed in the user specified location. Am I able to get the path/location of the destination drop? I would then proceed to download the file, and then place it where the use specified.
I have looked at other questions regarding a similar issue, which details the dragging operation outside the form, its just there doesn't appear to be a way to determine where that short cut went or how to flag the destination location.
Essentially, I am thinking that it may require some sort of 'dynamic link' or 'virtual file' as I've seen mentioned elsewhere. Then, after the drop operation, somehow accessing this 'link' from my application, proceed to download the file and place it in the final drop destination.
Any help is appreciated, thanks in advance!
OUTCOME:
Roger Lipscombe provided a link that contained links to other articles, with what looks to be promising information. The following links may prove useful in implementing a drag drop operation without providing the exact data that is required in managed code.
You can ask Explorer to delay an IDataObject::GetData call to CFSTR_FILEDESCRIPTOR to when the drop actually occurs by responding CFSTR_PREFERREDDROPEFFECT in your IDataObject::GetData implementation. See http://hg.mozilla.org/mozilla-central/file/b49a6a8a4973/widget/src/windows/nsDataObj.cpp for an example. Note if the target is a virtual folder, the drop target is not obligated to honor your preference.
Explorer check clipboard formats for file name in the folling order
CF_HDROP
CFSTR_FILEDESCRIPTOR/CFSTR_FILECONTENTS
CFSTR_FILENAME
Do not use CF_HDROP because it requires that the source file(s) actually exist somewhere in the file system. Use CFSTR_FILEDESCRIPTOR/CFSTR_FILECONTENTS instead.
Do you really want to know where the "file" was dropped? Or do you just not want to provide the data up front?
If the latter, Raymond Chen has a whole series on implementing virtual drag and drop, in native code. David Anson translates it into managed code and adds asynchronous support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With