How to tell "cut" from "copy" upon pasting
-
I'm developing a program that acts like file manager. Obviously it has to be able to cut/copy/paste files. When i cut and later paste within my application, I can set a flag that it was a >cut< operation and the files after being copied to destination should be removed from source location. However, if I am to cut/paste between my app and some external file manager (e.g. Windows Explorer) how can I (my program) tell whether it was >cut< selected, (not a >copy< operation) in the other application ? (also, what to put into clipboard when selecting cut from menu, so that the other application that will paste, would remove files after copying them to destination) ? Currently I'm using FileDrop type with String array of paths. But how can be encoded >cut< operation ? (some additional format, marker,..?) Thanks for help, Michal
-
I'm developing a program that acts like file manager. Obviously it has to be able to cut/copy/paste files. When i cut and later paste within my application, I can set a flag that it was a >cut< operation and the files after being copied to destination should be removed from source location. However, if I am to cut/paste between my app and some external file manager (e.g. Windows Explorer) how can I (my program) tell whether it was >cut< selected, (not a >copy< operation) in the other application ? (also, what to put into clipboard when selecting cut from menu, so that the other application that will paste, would remove files after copying them to destination) ? Currently I'm using FileDrop type with String array of paths. But how can be encoded >cut< operation ? (some additional format, marker,..?) Thanks for help, Michal
Most programs work like this: Cut/Copy/Delete is what happens on the source side; the steps are: 1. if not delete: copy selection to Clipboard 2. if not copy: delete selection THEN, on the destination side, a potential Paste pastes what is on the Clipboard to the current position, replacing/deleting whatever was selected there if anything. Now Windows Explorer acts differently: Cut dims the selection but does not delete it until it has been copied somewhere in some Explorer window, and I don't know how they do that. I can come up with ways to achieve that, within a single program, however I don't know which way MS has chosen. I expect there must be a message going back from destination to source to confirm the pasting is done, so the cutting should now be finalized. :)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
-
Most programs work like this: Cut/Copy/Delete is what happens on the source side; the steps are: 1. if not delete: copy selection to Clipboard 2. if not copy: delete selection THEN, on the destination side, a potential Paste pastes what is on the Clipboard to the current position, replacing/deleting whatever was selected there if anything. Now Windows Explorer acts differently: Cut dims the selection but does not delete it until it has been copied somewhere in some Explorer window, and I don't know how they do that. I can come up with ways to achieve that, within a single program, however I don't know which way MS has chosen. I expect there must be a message going back from destination to source to confirm the pasting is done, so the cutting should now be finalized. :)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
I'm trying to achive the same thing as explorer does and I think that there must be something else placed in clipboard (upon cuting, which results in imediate dimming items) that tells how pasting application should tread source files (leave intact or delete) upon completing paste operation. Thanks, Michal
-
I'm trying to achive the same thing as explorer does and I think that there must be something else placed in clipboard (upon cuting, which results in imediate dimming items) that tells how pasting application should tread source files (leave intact or delete) upon completing paste operation. Thanks, Michal
I guess I know now. It is a memory stream that is placed in Clipboard that tell whether to cut or copy only
const String PREFFERED_DROP_EFFECT_SHELL_CONSTANT = "Preferred DropEffect";
private bool IsItCutOperation(IDataObject dataObject)
{
Object isCutOperationMS = dataObject.GetData(PREFFERED_DROP_EFFECT_SHELL_CONSTANT) as MemoryStream;
if (isCutOperationMS == null)
return false;MemoryStream ms = isCutOperationMS as MemoryStream; byte\[\] array = new byte\[ms.Length\]; ms.Read(array, 0, (int)ms.Length); if(array\[0\] == (byte)(2)) // 5 copy, 2 cut { return true; } return false; }
Thanks, Michal
-
I guess I know now. It is a memory stream that is placed in Clipboard that tell whether to cut or copy only
const String PREFFERED_DROP_EFFECT_SHELL_CONSTANT = "Preferred DropEffect";
private bool IsItCutOperation(IDataObject dataObject)
{
Object isCutOperationMS = dataObject.GetData(PREFFERED_DROP_EFFECT_SHELL_CONSTANT) as MemoryStream;
if (isCutOperationMS == null)
return false;MemoryStream ms = isCutOperationMS as MemoryStream; byte\[\] array = new byte\[ms.Length\]; ms.Read(array, 0, (int)ms.Length); if(array\[0\] == (byte)(2)) // 5 copy, 2 cut { return true; } return false; }
Thanks, Michal
do you have any link or reference to such wisdom. You did not invent this yourself, did you? TIA
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
-
do you have any link or reference to such wisdom. You did not invent this yourself, did you? TIA
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
-
Drag and drop, cut/copy and paste files with Windows Explorer[^] I've found a code snippet in this article, and changed it a little to fit my needs. Regards, Michal
Thanks, :)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!