Clipboard

  • Thread starter Thread starter Beto
  • Start date Start date
B

Beto

In the moment when a user right click a file and select
the option cut or copy, the file is sent to the clipboard
(portapapeles).The question is:
-¿How can i know wich of the options(cut or copy) has
select the user?

Thanks.
 
Hi,

The .NET class doesn't directly provide this information, however if you
check the clipboard for the "Preferred DropEffect" format you can get to it.

Public Enum DropEffects
Invalid
Move
Copy
Unknown
End Enum

Public Function PreferredDropEffect() As DropEffects

Dim d As IDataObject
Dim m As System.IO.MemoryStream
Dim o As Object

' retrieve data currently on the clipboard
d = Clipboard.GetDataObject()

' retrieve data associated with CFSTR_PREFERREDDROPEFFECT
o = d.GetData("Preferred DropEffect")

' check presence of CFSTR_PREFERREDDROPEFFECT data
If Not IsNothing(o) Then

' get MemoryStream object returned
m = o

' look at the first byte
Select Case m.ReadByte

' copy
Case 2
Return DropEffects.Copy

' move
Case 5
Return DropEffects.Move

' unknown drop effect
Case Else
Return DropEffects.Unknown

End Select

Else

' no CFSTR_PREFERREDDROPEFFECT available
Return DropEffects.Invalid

End If

End Function

Regards,

Gabriele
 
Back
Top