R
Roger Norris
One of my development team's older apps uses the clipboard
formats CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR to
implement drag & drop functionality. From an MSDN article
on Shell Clipboard Formats, "These two formats are the
preferred way to transfer Shell objects that are not stored
as file-system files." The objects we're transfering are
not stored as file-system files, and we're also having to
use delayed rendering - two good reasons not to use the
more common CF_HDROP clipboard format.
We're now trying to start doing all new development with
..NET (C#). It is very important for our new apps to be
fully compatible with the old ones. However, so far I've
not been able to figure out a way to get our C# Windows
Forms app to support that clipboard format for drag & drop
operations.
The FILEDESCRIPTOR format is not a problem. The
IDataObject provided by the DragEventArgs will give me back
a byte stream which I can use to extract the names of the
files being dropped.
However, attempting to get at the FILECONTENTS object
results in nothing. The IDataObject doesn't return any
sort of object; it just returns null. Obviously, the names
of the files aren't very useful if I can't get at the data
which is supposed to go in them. Also, even if it did
work, I can see no way to specify which file to retrieve.
In our MFC C++ app, the call to GetData would allow us to
specify the index of the file we wanted in the FORMATETC
parameter. But .NET's IDataObject.GetData doesn't have an
analagous parameter.
Can someone offer a way to support that clipboard format in
a C# Windows Forms app?
formats CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR to
implement drag & drop functionality. From an MSDN article
on Shell Clipboard Formats, "These two formats are the
preferred way to transfer Shell objects that are not stored
as file-system files." The objects we're transfering are
not stored as file-system files, and we're also having to
use delayed rendering - two good reasons not to use the
more common CF_HDROP clipboard format.
We're now trying to start doing all new development with
..NET (C#). It is very important for our new apps to be
fully compatible with the old ones. However, so far I've
not been able to figure out a way to get our C# Windows
Forms app to support that clipboard format for drag & drop
operations.
The FILEDESCRIPTOR format is not a problem. The
IDataObject provided by the DragEventArgs will give me back
a byte stream which I can use to extract the names of the
files being dropped.
However, attempting to get at the FILECONTENTS object
results in nothing. The IDataObject doesn't return any
sort of object; it just returns null. Obviously, the names
of the files aren't very useful if I can't get at the data
which is supposed to go in them. Also, even if it did
work, I can see no way to specify which file to retrieve.
In our MFC C++ app, the call to GetData would allow us to
specify the index of the file we wanted in the FORMATETC
parameter. But .NET's IDataObject.GetData doesn't have an
analagous parameter.
Can someone offer a way to support that clipboard format in
a C# Windows Forms app?