home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Drag_To_Ex215183582009.psc / readme.txt < prev    next >
Text File  |  2009-05-08  |  2KB  |  24 lines

  1. Hack-around by Michael Redwine (michael@phuzz.net)
  2. --------------------------------------------------
  3. Drag To Explorer:
  4.  
  5. This project demonstrates something that is really hard to find out there in VB-land: a way to drag a listitem from a listview into explorer and return the dropped path, thereby allowing you to do whatever it is you want to do.  When searching online, you find this question a lot, but nobody seems to answer the question that was asked, or provides some other answer that doesn't do any good.
  6.  
  7. The method I use to accomplish this is somewhat of a hack, but it works.
  8.  
  9. Check out the source and hope it works for you!  It does for me...!
  10.  
  11. Below is a basic concept of how I perform this magic.
  12.  
  13. * The following techniques are used to accomplish this task: ShellFileOps to use the recycle bin, ShellNotify to be alerted when files are created in the filesystem, and GetTempFileName() to create a temporary file (which is recycled, not left behind).
  14. * Populate the listview with whatever it is you need.
  15. * Drag a listitem to the desktop (or any other explorer window/location).
  16. * When the drag operation starts, set the AllowedEffects to vbDropEffectCopy.
  17. * When the drag operation enters an explorer location, create a temp file and add it to the Data.Files() object.
  18. * When you complete your drag operation, the temp file is moved from it's current location in the temp folder to where you dropped the list item in explorer.  This is handled automatically because of AllowedEffects.
  19. * ShellNotify will grab the temp file's new location.
  20. * Whala!  You now know where you dragged your listitem to.
  21. * Cleanup: Use ShellFileOps to send the temp file to the recycle bin with permanent delete and no dialog.
  22. * After that, do whatever you need to do with the DroppedFolder location!
  23.  
  24.