EnumMetaFile

2.x

  BOOL EnumMetaFile(hdc, hmf, mfenmprc, lParam)    
  HDC hdc; /* handle of device context */
  HLOCAL hmf; /* handle of metafile, */  
  MFENUMPROC mfenmprc; /* address of callback function */
  LPARAM lParam; /* application-defined data */

The EnumMetaFile function enumerates the metafile records in a given metafile. EnumMetaFile continues until there are no more graphics device interface (GDI) calls or the callback function returns zero.

Parameters

hdc

Identifies the device context associated with the metafile.

hmf

Identifies the metafile.

Note:

The HLOCAL type for this parameter is incorrect in the WINDOWS.H file. The type of this parameter is actually HMETAFILE. Developers should cast this parameter to an HLOCAL type to avoid compiler warnings.

mfenmprc

Specifies the procedure-instance address of the application-supplied callback function. The address must be created by using the MakeProcInstance function. For more information about the callback function, see the description of the EnumMetaFileProc callback function.

lParam

Specifies a 32-bit application-defined value that is passed to the callback function along with the metafile information.

Return Value

The return value is nonzero if the callback function enumerates all the GDI calls in a metafile. Otherwise, it is zero.

Comments

The EnumMetaFile function retrieves metafile records and passes them to a callback function. An application can modify the metafile record inside the callback function. The application can also use the PlayMetaFileRecord function inside the callback function; this is useful for very large metafiles, when using the PlayMetaFile function might be time-consuming.

Example

The following example creates a dashed green pen and passes it to the callback function for the EnumMetaFile function. If the first element in the array of object handles is a handle, that handle is replaced by the handle of the green pen before the PlayMetaFileRecord function is called. (For this example, it is assumed that the table of object handles contains only one handle and that it is the handle of a pen.)

MFENUMPROC lpEnumMetaProc;
HPEN hpenGreen;

lpEnumMetaProc = (MFENUMPROC) MakeProcInstance(
    (FARPROC) EnumMetaFileProc, hAppInstance);
hpenGreen = CreatePen(PS_DASH, 1, RGB(0, 255, 0));
EnumMetaFile(hdc, hmf, lpEnumMetaProc, (LPARAM) &hpenGreen);
FreeProcInstance((FARPROC) lpEnumMetaProc);
DeleteObject(hpenGreen);
    .
    .
    .

int FAR PASCAL EnumMetaFileProc(HDC hdc, HANDLETABLE FAR* lpHTable,
    METARECORD FAR* lpMFR, int cObj, BYTE FAR* lpClientData)
{
    if (lpHTable->objectHandle[0] != 0)
        lpHTable->objectHandle[0] = *(HPEN FAR *) lpClientData;
    PlayMetaFileRecord(hdc, lpHTable, lpMFR, cObj);

    return 1;
}

See Also

EnumMetaFileProc, MakeProcInstance, PlayMetaFile, PlayMetaFileRecord