|
-
Jul 2nd, 2009, 03:31 AM
#1
Thread Starter
Addicted Member
[RESOLVED] OLE Drag & Drop from ListView to Explorer
I have some items in a listview and I want the user to be able to choose the export format (.csv, .txt, ...).
I have already made the export functions and can do it through the menus.
What I want is to be able to drag some items from the listview to an explorer window (eg. desktop), show a menu of file formats and export according to the selection (or cancel the procedure if nothing selected).
I found this but the files must exist in the data collection on OLEStartDrag.
I want the files to be added after the menu selection.
How can I do that?
-
Jul 2nd, 2009, 05:16 AM
#2
Re: OLE Drag & Drop from ListView to Explorer
Cant you have a dummy file just to initialise the drag drop and then show the menu ?
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Jul 2nd, 2009, 05:24 AM
#3
Thread Starter
Addicted Member
Re: OLE Drag & Drop from ListView to Explorer
I tried that but, as soon as OLECompleteDrag fires, the system moves the file immediately to the drop point and (asynchronously) the popupmenu appears.
If I try to keep it open on StartDrag, in order to close it on CompleteDrag, the system complains that the file is in use.
-
Jul 2nd, 2009, 09:29 AM
#4
Thread Starter
Addicted Member
Re: OLE Drag & Drop from ListView to Explorer
The guy in this thread said he had managed to do what I'm trying to do now.
Can someone explain further what he did?
Last edited by Cube8; Jul 2nd, 2009 at 09:32 AM.
-
Jul 2nd, 2009, 10:36 AM
#5
Re: OLE Drag & Drop from ListView to Explorer
This is what I believe is the workaround. Note, the trick is to not set the data in OLEStart, but set it in OLESetData. Of course, you have to provide a minimum of the data format and allowed effects in OLEStart or no drag operation occurs.
1. In the OLEStart event
Code:
Data.Clear
Data.SetData , vbCFFiles
AllowedEffects = vbDropEffectCopy ' add move also if desired
2. In the OLESetData event
Code:
If GetKeyState(vbLeftButton) = 0& Then
PopupMenu mnuFormat ' << add your own menu control name
Data.Files.Add [full path & file name] ' of each file
' ^^ this cannot be done in your menu routine unless you pass the Data object
End If
-
Jul 3rd, 2009, 01:33 AM
#6
Thread Starter
Addicted Member
Re: OLE Drag & Drop from ListView to Explorer
Thank you, LaVolpe.
I already managed to do this trick just before you post the code.
Also, using the Debug.Print method, I discovered that OLESetData event fires several times before actually dropping the "file", and GetKeyState sometimes returns 1.
Anyway, thanks for your response and, if you would like, I'll post the final code inside OLESetData.
-
Jul 3rd, 2009, 11:00 AM
#7
Re: [RESOLVED] OLE Drag & Drop from ListView to Explorer
I think posting the code could help others. I do recall someone having a similar problem over a year ago: wanted to unzip data to target directory, but didn't want the zip dropped. Like you, they wanted to know when the target was actually dropped but before the CompleteDrag event.
-
Jul 7th, 2009, 01:50 AM
#8
Thread Starter
Addicted Member
Re: [RESOLVED] OLE Drag & Drop from ListView to Explorer
I posted the code in the CodeBank forum: Drag & Drop ListView items to Explorer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|