SetClipboardData

This function places data on the clipboard in a specified clipboard format.

At a Glance

Header file: Winuser.h
Windows CE versions: 1.0 and later

Syntax

HANDLE SetClipboardData(UINT uFormat, HANDLE hMem);

Parameters

uFormat

[in] Unsigned integer that specifies a clipboard format. This parameter can be a registered format or any of the standard clipboard formats. Windows CE supports the following standard clipboard:

Value Description
CF_BITMAP A handle to a bitmap (HBITMAP).
CF_DIB A memory object containing a BITMAPINFO structure followed by the bitmap bits.
CF_DIF Software Arts' Data Interchange Format.
CF_PALETTE Handle of a color palette. Whenever an application places data in the clipboard that depends on or assumes a color palette, it should place the palette on the clipboard as well.
If the clipboard contains data in the CF_PALETTE (logical color palette) format, the application should use the SelectPalette and RealizePalette functions to realize (compare) any other data in the clipboard against that logical palette.
When displaying clipboard data, the clipboard always uses as its current palette any object on the clipboard that is in the CF_PALETTE format.
CF_PENDATA Data for the pen extensions to the Microsoft® Windows® for Pen Computing.
CF_RIFF Represents audio data more complex than can be represented in a CF_WAVE standard wave format.
CF_SYLK Microsoft Symbolic Link (SYLK) format.
CF_TEXT Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
CF_WAVE Represents audio data in one of the standard wave formats, such as 11 kHz or 22 kHz pulse code modulation (PCM).
CF_TIFF Tagged-image file format.
CF_UNICODETEXT Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.

hMem

[in] Handle to the data in the specified format. This parameter can be NULL, indicating that the window provides data in the specified clipboard format (renders the format) upon request. If a window delays rendering, it must process the WM_RENDERFORMAT and WM_RENDERALLFORMATS messages.

After SetClipboardData is called, the system owns the object identified by the hMem parameter. The application can read the data, but must not free the handle or leave it locked. If the hMem parameter identifies a memory object, the object must have been allocated using the LocalAlloc function.

Return Values

The handle of the data indicates success. NULL indicates failure. To get extended error information, call GetLastError.

Remarks

The data to be set into the clipboard should be allocated using the LocalAlloc function.

Windows CE does not perform any implicit conversions between formats.

The window must be the current clipboard owner, and the application must have called the OpenClipboard function.

The system performs implicit data format conversions between certain clipboard formats when an application calls the GetClipboardData function. For example, if the CF_OEMTEXT format is on the clipboard, a window can retrieve data in the CF_TEXT format. The format on the clipboard is converted to the requested format on demand.

See Also

BITMAPINFO, GetClipboardData, OpenClipboard, RegisterClipboardFormat, WM_DESTROYCLIPBOARD, WM_RENDERFORMAT, WM_RENDERALLFORMATS