2.14.4 Changing How Windows Plays a Metafile

A metafile does not have to be played back in its entirety or exactly in the form in which it was recorded. An application can use the EnumMetaFile function to locate a specific metafile record. EnumMetaFile calls an application-supplied callback function and passes it the following:

The metafile device context

A pointer to the metafile handle table

A pointer to a metafile record

The number of associated objects with handles in the handle table

A pointer to application-supplied data

The callback function can then use this information to play a single record, to query it, copy it, or modify it. The PlayMetaFileRecord function plays a single metafile record.

When Windows plays or enumerates the records in a metafile, it identifies each object with an index into a handle table. Functions that select objects (such as SelectObject and SelectPalette) identify the object by means of the object handle which the application passes to the function.

Objects are added to the table in the order in which they are created. For example, if a brush is the first object created in a metafile, the brush is given index zero. If the second object is a pen, it is given index 1, and so on. See the description of the HANDLETABLE data structure in Chapter 7, “Data Types and Structures” for information on the format of the handle table.