[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Convert custom object on the clipboard dynamically when pasted

simonjarita

9/10/2007 9:06:00 AM

i'm using the clipboard and drag&drop to transport data (in its native
format) whithin my application. now i would like to provide this data
in other formats (like text and csv) to other applications.

however, i don't want to convert the data into the other formats
already at the moment when i put it on the clipboard as it can be very
large and will slow down copying and pasting within my app
considerably. i would rather show to the receiving application that
the object is available as text for example and convert it only when
it is actually pasted.

i thought the following:
my object can implement the IDataObject interface and and return all
the supported formats when they are required.
what i don't understand is: how is the data object actually
transported outside my app? do i have to implement the ISerializable
interface as well? when member methods of the data objects are called
the call comes from a different process, no? what happens if my app is
not loaded and methods of the data object are called?

thank you for any help,

simon m.

1 Answer

Michael Phillips, Jr.

9/11/2007 3:58:00 PM

0

> i'm using the clipboard and drag&drop to transport data (in its native
> format) whithin my application. now i would like to provide this data
> in other formats (like text and csv) to other applications.
>
> however, i don't want to convert the data into the other formats
> already at the moment when i put it on the clipboard as it can be very
> large and will slow down copying and pasting within my app
> considerably. i would rather show to the receiving application that
> the object is available as text for example and convert it only when
> it is actually pasted.
>
> i thought the following:
> my object can implement the IDataObject interface and and return all
> the supported formats when they are required.
> what i don't understand is: how is the data object actually
> transported outside my app? do i have to implement the ISerializable
> interface as well? when member methods of the data objects are called
> the call comes from a different process, no? what happens if my app is
> not loaded and methods of the data object are called?

For very simple clipboard data operations, you may use SetClipboardData with
a NULL handle.

When your application is sent the WM_RENDERFORMAT and WM_RENDERALLFORMATS
messages, then your application renders the data.

If you choose to implement IDataObject, then your implementation declares
the method used to render the data.

You may use a handle to global memory, an IStream or IStorage interface,
etc. to represent your data.

In all of the above choices, whatever you place on the clipboard is owned
and maintained by the clipboard not your application.

You application must not free or write to any of the data once the data is
placed on the clipboard.

Even if you do not want to convert the data to another format, the clipboard
will synthesize certain formats for the client.

MSDN has all the information that you need to implement clipboard data
transfer correctly.