Le 20 août 06 à 01:46 Matin, Carlo Rubini a écrit:
From: Arnaud Nicolet <[EMAIL PROTECTED]>
Le 18 ao=FBt 06 =E0 04:26 Matin, Carlo Rubini a =E9crit:
Following the documentation, it is possible to drag items from a =20
listBox to the desktopFolder.
What about dragging items from a listbox to a different folder?
Different than what?
If you drag the text of a cell of a listbox to a folder, it will =20
appear as a clip file.
If you drag the same text to a different folder, the clip file
will =20
appear in that different folder, simply.=
Yep, simple. Let me refrase it:
the cellTags of the rows contain references to files, and I want to
copy (or move) the referenced files to a folder different than the
desktopFolder.
At present the code in the dragRow event is:
For i=0 to nRows
If Me.Selected(i) then
f = GetFolderItem(me.CellTag(i,0))
if f <> nil and f.Exists then
f.CopyFileTo DesktopFolder
end if
End if
Next
By the way: you should avoid using absolute paths, if possible. Since
a CellTag is a variant, you might consider storing directly a
folderitem rather than a string to the cell tag.
but I would like to be able to copy the folderitems into the folder
over which I'm doing the dragging.
If possible, how should the above code be changed?
The problem is that the drag is handled automatically by the Finder.
At least, you can know where the file was dropped:
When you have your dragItem, set its folderitem property to the file,
do the drag, and watch for the destination property.
I guess I'd do something like:
'd is a DragItem, already defined.
'f is a file you want to drag
dim Folder As FolderItem
d.FolderItem=f
d.Drag
'Here, the drag has finished (either the file(s) has/have been
dropped, either the drag has been cancelled).
if d.Destination IsA folderItem then
Folder=FolderItem(d.Destination)
end if
Now, you know that your file has been sent to the Folder variable.
A drag to the Finder is handled by itself (as you can see while you
drag a file, even from within your application, if you hold down the
option key, the arrow cursor changes to a "copy-arrow" cursor. That's
a proof (also, it acts so)). So the move/copy/make alias operation
(given the keys held down by the user) will anyway be done before you
do anything from your code.
But, now, if you wanted to make a copy, you can copy the file in the
opposite sense (from the destination to its original folder), since
you can figure the destination's folder with the code above.
If you wanted to make a move and you see that the file has been
duplicated, you may remove the original file.
In the other hand, you can do it in another way: put something the
Finder accepts in the drag (for example, a text, accepted as a clip
file) and only that (not the actual file), do the drag, use the code
above to figure out where the clip file has been created, delete the
clip file (look for clip files containing your specific-and-
recognizable text) and use CopyFileTo, or MoveFileTo, now that no
real file handling has been done from the Finder.
The drag to a folder seems limited by the fact that it is handled
automatically, but there are plenty options to checks, that depends
on how you want to do that. Hope this help.
Meanwhile, thanks for answering,
You're welcome.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>