|
-
Jan 3rd, 2010, 09:42 PM
#1
Thread Starter
New Member
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.
-
Jan 4th, 2010, 10:21 AM
#2
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:
' Delcarations Private Declare Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer Private Const VK_LEFT As Long = &H25 ' sample usage, change Picture1 to your object that is being dragged Private Sub Picture1_OLEStartDrag(Data As DataObject, AllowedEffects As Long) ' change effects as needed AllowedEffects = vbDropEffectCopy Or vbDropEffectMove Data.Clear Data.SetData , vbCFFiles ' by not actually populating data, we get the SetData event End Sub Private Sub Picture1_OLESetData(Data As DataObject, DataFormat As Integer) If GetKeyState(VK_LEFT) > -1 Then ' test for left mouse button up (user made decision) ' unzip/transfer files to user's temp path. ' else unzip/transfer files to other writable path ' now add the temp path/filenames to the data object ' i.e., Data.Files.Add .... End If End Sub Private Sub Picture1_OLECompleteDrag(Effect As Long) ' clean up the temp path/files. Remove them If Effect = vbDropEffectMove Then ' remove these from your server if you offered that option End If End Sub
Here is an example of the GetTempPath API
Last edited by LaVolpe; Jan 4th, 2010 at 11:36 AM.
-
Jan 4th, 2010, 10:52 AM
#3
Thread Starter
New Member
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.
-
Jan 4th, 2010, 11:01 AM
#4
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.
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
|