Results 1 to 8 of 8

Thread: [RESOLVED] OLE Drag & Drop from ListView to Explorer

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    229

    Resolved [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?

  2. #2
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    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.



  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    229

    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.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    229

    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.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    229

    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.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    229

    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
  •  



Click Here to Expand Forum to Full Width