IVsObjectList2.EnumClipboardFormats Method

Asks the given list item to enumerate its supported clipboard formats.

Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop.8.0 (in microsoft.visualstudio.shell.interop.8.0.dll)

int EnumClipboardFormats (
	[InAttribute] uint index,
	[InAttribute] uint grfFlags,
	[InAttribute] uint celt,
	[OutAttribute] VSOBJCLIPFORMAT[] rgcfFormats,
	[OptionalAttribute] [OutAttribute] uint[] pcActual
int EnumClipboardFormats (
	/** @attribute InAttribute() */ UInt32 index, 
	/** @attribute InAttribute() */ UInt32 grfFlags, 
	/** @attribute InAttribute() */ UInt32 celt, 
	/** @attribute OutAttribute() */ VSOBJCLIPFORMAT[] rgcfFormats, 
	/** @attribute OutAttribute() */ /** @attribute OptionalAttribute() */ UInt32[] pcActual
function EnumClipboardFormats (
	index : uint, 
	grfFlags : uint, 
	celt : uint, 
	rgcfFormats : VSOBJCLIPFORMAT[], 
	pcActual : uint[]
) : int



[in] Specifies the index of the list item of interest.


[in] Specifies multi-selection. Values are taken from the _VSOBJCFFLAGS enumeration.


[in] Specifies the element count of rgcfFormats.


[in, out] Specifies an array of VSOBJCLIPFORMAT structures defining the formats supported.


[out] Pointer to a count of formats in the rgcfformats array actually returned.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

COM Signature

From vsshell80.idl:

HRESULT IVsObjectList2::EnumClipboardFormats(
   [in] ULONG Index, 
   [in] VSOBJCFFLAGS grfFlags, 
   [in] ULONG celt, 
   [in, out, size_is(celt)] VSOBJCLIPFORMAT rgcfFormats[], 
   [out, optional] ULONG *pcActual

The environment supports three standard clipboard formats: CF_NAVINFO, CF_TEXT, and CF_UNICODETEXT. You may create and register your own clipboard formats. For information on OLE clipboard format implementation and registration, see Clipboard Formats in the MSDN Library Platform SDK documentation set.

The environment calls EnumClipboardFormats to obtain a list of clipboard formats that you support for drag-drop and copy-paste operations. The environment first calls EnumClipboardFormats (index, grfFlags, 0, null, pcActual) to get the count of clipboard formats your list provides. It then allocates an array of size pcActual, and then calls EnumClipboardFormats (index, grfFlags, pcActual, rcgfFormats, pcActual).

Fill the rgcfformats array with VSOBJCLIPFORMAT structures containing the formats you support. Each VSOBJCLIPFORMAT structure identifies the format, the type of medium, and whether the format is a composite one. With composite formats, the environment does the actual rendering after calling GetExtendedClipboardVariant. Otherwise, the list itself does the rendering through GetClipboardFormat. In the case of multiple selections, you would only support composite formats. This enables the environment to write the format in the form: <count of items><xyz variant from selected item1><xyz variant from selected item2>.


Only certain VARIANT types that can be persisted are supported as covered in CComVariant::WriteToStream in the MSDN Library Platform SDK documentation set.

In the single selection case, your object list is free to provide both traditional and composite formats and is called respectively on GetClipboardFormat or GetExtendedClipboardVariant for each.


Class View and Object Browser automatically provide a CF_NAVINFO and a CF_TEXT/CF_UNICODETEXT format, so EnumClipboardFormats should not return these values.

Community Additions