To copy data to the clipboard, you format the data by using either a predefined or private format. For most formats, you allocate global memory and copy the data into it. You then use the SetClipboardData function to copy the memory handle to the clipboard.
In Windows applications, copying and pasting are carried out through Edit-menu commands. To add Edit menu to an application, follow the steps described in Chapter 7, “Menus.”
Windows provides several predefined data formats for use in data interchange. The following list describes the clipboard formats:
Value | Meaning |
CF_BITMAP | The data is a bitmap. |
CF_DIB | The data is a memory object containing a BITMAPINFO structure followed by the bitmap data. |
CF_DIF | The data is in Data Interchange Format (DIF). |
CF_DSPBITMAP | The data is a bitmap representation of a private format. This data is displayed in bitmap format in lieu of the privately formatted data. |
CF_DSPMETAFILEPICT | The data is a metafile representation of a private data format. This data is displayed in metafile-picture format in lieu of the privately formatted data. |
CF_DSPTEXT | The data is a textual representation of a private data format. This data is displayed in text format in lieu of the privately formatted data. |
CF_METAFILEPICT | The data is a metafile (see the description of the METAFILEPICT structure in the Microsoft Windows Programmer's Reference, Volume 3). |
CF_OEMTEXT | The data is an array of text characters in the OEM character set. Each line ends with a carriage return–linefeed (CR-LF) combination. A null character signals the end of the data. |
CF_OWNERDISPLAY | The data is in a private format that the clipboard owner must display. |
CF_PALETTE | The data is a color palette. |
CF_PENDATA | The data is for the pen extensions to the Windows operating system. |
CF_RIFF | The data is in Resource Interchange File Format (RIFF). |
CF_SYLK | The data is in Microsoft Symbolic Link (SYLK) format. |
CF_TEXT | The data is an array of text characters. Each line ends with a carriage return–linefeed (CR-LF) combination. A null character signals the end of the data. |
CF_TIFF | The data is in Tag Image File Format (TIFF). |
CF_WAVE | The data describes a sound wave. This is a subset of the CF_RIFF data format; it can be used only for RIFF WAVE files. |
When you paste data from the clipboard by using the GetClipboardData function, you specify the format you expect. The clipboard supplies the data only if it has been copied in that format.
Windows supports two formats for text, CF_TEXT and CF_OEMTEXT. CF_TEXT is the default Windows text clipboard format. Windows uses the CF_OEMTEXT format for text in non-Windows applications. If you call GetClipboardData to retrieve data in one text format and discover that the other text format is the only one available, Windows automatically converts the text to the requested format before supplying it to your application.
Note:
Clipboard data objects can be any size. Your application must be able to work with clipboard data objects larger than 64K. For more information about working with large data objects, see Chapter 16, “More Memory Management.”