Results 1 to 4 of 4

Thread: Get OLEDrop Path

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    10

    Get OLEDrop Path

    Hi,

    is it possible to get drop path of OLE. i have a listview and there is file names. i ll drag and drop a file name to the desktop, in this moment can i get path of the desktop ? i ll use winsock so i can not use adding file event. i just need to get path of dropped zone.

    thanks in advance.

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

    Re: Get OLEDrop Path

    Knowing the drop path generally isn't a big deal. The target will decide where to place the files and with Vista, this may be a virtual folder different than the target. Getting the drop path may require some serious hacking if it is possible and would be target-specific.

    There is a workaround when the files are not physically on the target system which sounds like your scenario... How can you drop/transfer the files if you don't know where to transfer them to? Answer: save them to a temp path & let the target transfer from there to actual location. Another scenario are files that take time to process before dropped, like zips, don't want to prematurely unzip/process if user is going to cancel the operation, do you?

    Here are two workarounds
    1. Reactive. Transfer/unzip files to user's temp path. Add the files to the Data object and remove the files after drag/drop complete, whether canceled or not.
    2. Proactive. Wait until the user makes a decision, then transfer/unzip the files to user's temp path and add those files to the data object.
    vb Code:
    1. ' Delcarations
    2. Private Declare Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
    3. Private Const VK_LEFT As Long = &H25
    4.  
    5. ' sample usage, change Picture1 to your object that is being dragged
    6. Private Sub Picture1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
    7.     ' change effects as needed
    8.     AllowedEffects = vbDropEffectCopy Or vbDropEffectMove
    9.     Data.Clear
    10.     Data.SetData , vbCFFiles ' by not actually populating data, we get the SetData event
    11. End Sub
    12. Private Sub Picture1_OLESetData(Data As DataObject, DataFormat As Integer)
    13.     If GetKeyState(VK_LEFT) > -1 Then ' test for left mouse button up (user made decision)
    14.         ' unzip/transfer files to user's temp path.
    15.         ' else unzip/transfer files to other writable path
    16.      
    17.         ' now add the temp path/filenames to the data object
    18.         ' i.e., Data.Files.Add ....
    19.     End If
    20. End Sub
    21. Private Sub Picture1_OLECompleteDrag(Effect As Long)
    22.     ' clean up the temp path/files. Remove them
    23.     If Effect = vbDropEffectMove Then
    24.        ' remove these from your server if you offered that option
    25.     End If
    26. End Sub
    Here is an example of the GetTempPath API
    Last edited by LaVolpe; Jan 4th, 2010 at 11:36 AM.
    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}

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    10

    Re: Get OLEDrop Path

    LaVolpe,

    thank you so much for your reply. if i understand well there is no way to get path of drop zone. maybe i should to use common dialog then it will be better for process.

    thank you again.

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

    Re: Get OLEDrop Path

    I wouldn't say there is no way to get the path, but it would be target specific. What if user drops files to explorer, desktop, custom app, a remote server like an FTP, etc, etc. IMO, your app should only be responsible for making the files available, not actually doing the transfer if OLE drag/drop is being used.

    If you are going to use a common dialog, then ensure you use appropriate error checking, as user can drop to unwritable paths (lacking permissions).

    An ideal situation may be to support both, allow drag/drop and also allow transfer via a dialog.
    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}

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