The Standard Clipboard Data Formats

Windows supports various standard clipboard formats that have WINDOWS.H identifiers. These are:

CF_TEXT—a NULL-terminated ANSI character-set character string containing a carriage return and a linefeed character at the end of each line. This is the simplest form of clipboard data. The data to be transferred to the clipboard is stored in a global memory block and is transferred using the handle to the block. The memory block becomes the property of the clipboard, and the program that creates the block should not continue to use it.

CF_BITMAP—a Windows 2–compatible bitmap. The bitmap is transferred to the clipboard using the bitmap handle. Again, a program should not continue to use this bitmap after giving it to the clipboard.

CF_METAFILEPICT—a ”metafile picture.“ This isn't exactly the same as a metafile (described in Chapter 13). Rather, it's a metafile with some additional information in the form of a small structure of type METAFILEPICT. A program transfers a metafile picture to the clipboard using the handle to a global memory block containing this structure. The four fields of the METAFILEPICT structure are mm (int), the mapping mode for the metafile; xExt (int) and yExt (int), in simple terms, the width and height of the metafile image; and hMF (HANDLE), the handle to the metafile. (I'll discuss the xExt and yExt fields in detail later in this chapter.) After a program transfers a metafile picture to the clipboard, it should not continue to use either the global memory block containing the METAFILEPICT structure or the metafile handle, because both will be under the control of the USER module.

CF_SYLK—a global memory block containing data in the Microsoft ”Symbolic Link“ format. This format is used for exchanging data between Microsoft Corporation's Multiplan, Chart, and Excel programs. It is an ASCII format with each line terminated with a carriage return and linefeed.

CF_DIF—a global memory block containing data in the Data Interchange Format (DIF). This is a format devised by Software Arts for use with transferring data to the VisiCalc spreadsheet program. The format is now under the control of Lotus Corporation. This is also an ASCII format with lines terminated with carriage returns and linefeeds.

The CF_SYLK and CF_DIF formats are conceptually similar to the CF_TEXT format. However, character strings containing SYLK or DIF data are not necessarily NULL-terminated, because the formats define the end of the data. (For descriptions of these two formats, see Jeff Walden, File Formats for Popular PC Software, John Wiley & Sons, 1986.)

CF_TIFF—a global memory block containing data in the Tag Image File Format (TIFF). This is a format devised by Microsoft, Aldus Corporation, and Hewlett-Packard Company in conjunction with some hardware manufacturers. The format (which describes bitmapped data) is available from Hewlett-Packard.

CF_OEMTEXT—a global memory block containing text data (simple to CF_TEXT) but using the OEM character set.

CF_DIB—a global memory block defining a device-independent bitmap. The global memory block begins with a BITMAPINFO structure followed by the bitmap bits.

CF_PALETTE—a handle to a color palette. This is generally used in conjunction with CF_DIB for defining a color palette used by the bitmap.