Choosing formats when putting data on clipboard

The topic is from a forum discussion at

Generally an application should provide data in as many formats as possible so more applications can recognize the data. For example, IE stores text data in CF_UNICODETEXT, CF_TEXT and CF_HTML formats.

Because a lot of application would stop enumerating the clipboard on first supported format, to avoid data lose in round trips, clipboard formats that contain the most information should be placed on the clipboard first, followed by less descriptive formats. For example, CF_HTML first, CF_UNICODETEXT second and CF_TEXT last. Sometimes you get to choose from the paste format (e.g. paste special in Microsoft Word), but that’s the exception, not many program can paste the format that is not the first supported format (e.g. you don’t have paste special in Microsoft Paint).

Of course sometimes you want to limit, say, the format being exposed to the clipboard, e.g. when copying code from Visual Studio but expect the code to make a round trip back to Visual Studio without the formatting, then you may want to put a less descriptive format first. 

If using the webbrowser control as the text editor, you can remove the formatting in pasting by implementing OnFilterDataObject.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.