Export (0) Print
Expand All

Clipboard: Adding Other Formats

This topic explains how to expand the list of supported formats, particularly for OLE support. The topic Clipboard: Copying and Pasting Data describes the minimum implementation necessary to support copying and pasting from the Clipboard. If this is all you implement, the only formats placed on the Clipboard are CF_METAFILEPICT, CF_EMBEDSOURCE, CF_OBJECTDESCRIPTOR, and possibly CF_LINKSOURCE. Most applications will need more formats on the Clipboard than these three.

Registering Custom Formats

To create your own custom formats, follow the same procedure you would use when registering any custom Clipboard format: pass the name of the format to the RegisterClipboardFormat function and use its return value as the format ID.

Placing Formats on the Clipboard

To add more formats to those placed on the Clipboard, you must override the OnGetClipboardData function in the class you derived from either COleClientItem or COleServerItem (depending on whether the data to be copied is native). In this function, you should use the following procedure.

To place formats on the Clipboard

  1. Create a COleDataSource object.
  2. Pass this data source to a function that adds your native data formats to the list of supported formats by calling COleDataSource::CacheGlobalData.
  3. Add standard formats by calling COleDataSource::CacheGlobalData for each standard format you want to support.

This technique is used in the MFC OLE sample program HIERSVR (examine the OnGetClipboardData member function of the CServerItem class). The only difference in this sample is that step three is not implemented because HIERSVR supports no other standard formats.

What do you want to know more about?

See Also

Clipboard: Using the OLE Clipboard Mechanism

Show:
© 2014 Microsoft