
Clipboard and Explorer : how to distinguish betwwen "Copy"/"Cut" ?
Quote:
> > > is there a way to check which function (either "copy" or "cut") was
used
> > > when a user highlights one or several files and cuts/copies them to
the
> > > clipboard ?
> > As far as I know, the answer is "no". A basic question for you is "Why
do
> > you need or want to know?".
> Hi Jay,
> there MUST be a way to determine this :)
> I just want to re-implement the Explorer's "Paste" facility (with special
> features).
> Scenario as follows :
> - user highlights several files or folders and says either "copy" or "cut"
> - instead of doing the "paste" process with the Windows explorer I want to
> run my program
> - the program would then extract file/folder name from the Clipboard and
> then run ShFileOperation() with additional parameters, but needs to
> distinguish between "copy" and "cut"
In general terms, "Paste" is enabled by something being in the clipboard.
The clipboard has no idea how the data got there. It doesn't even have to
come from "copy" or "cut". Any program can open the clipboard and put data
there whenever it wants.
"Cut" is often implemented as "copy" followed by delete. However, there are
notable exceptions (e.g. Excel, where "cut" doesn't delete the selected
cells until the "paste" is done - more like a "move", IMO).
Since your only access point is the clipboard, you really have no way of
knowing who, why, or how the data got there (unless you put it there
yourself). I would wager it's tricky if not nearly impossible (I qualify it
since the system knows on some level for delayed rendering) to even know
which app put the data on the clipboard.
Since you still haven't described how the behavior would differ for "copy"
vs. "cut", I can't offer a workaround or alternate suggestion. The one thing
to keep in mind is that the copy/cut behavior is at the discretion of the
app that places the data on the clipboard. The pasting app shouldn't do
anything to the source data (e.g. you should be able to paste data/files
into as many different apps as you want). The data placed on the clipboard
is the property of the cut/copy app, not the pasting one.
HTH
--
Jay