SetWinMetaFileBits

  HENHMETAFILE SetWinMetaFileBits(cbBuffer, lpbBuffer, hdcRef, lpmfp)    
  UINT cbBuffer; /* size of buffer */
  LPBYTE lpbBuffer; /* address of buffered metafile data */
  HDC hdcRef; /* handle of reference device-context */
  LPMETAFILEPICT lpmfp; /* contains suggested size of metafile picture */

The SetWinMetaFileBits function converts a metafile from the older windows format to the new enhanced format and stores the new metafile in memory.

Parameters

cbBuffer

Specifies the size, in bytes, of the buffer that contains the windows-format metafile.

lpbBuffer

Points to a buffer that contains the Windows 3.x metafile data. It is assumed that the data was previously created using the GetMetaFileBitsEx or GetWinMetaFileBits function.

hdcRef

Identifies a reference device.

lpmfp

Points to a METAFILEPICT structure that contains the suggested size of the metafile picture and the mapping mode that was used when the picture was created. The METAFILEPICT structure has the following form:

typedef struct tagMETAFILEPICT { /* mfp */

DWORD mm;

DWORD xExt;

DWORD yExt;

HMETAFILE hMF;

} METAFILEPICT;

Return Value

The return value identifies a memory-based enhanced metafile if the function is successful. Otherwise, it is NULL. Use the GetLastError function to obtain extended error information.

Comments

Windows uses the reference device's resolution data and the data in the METAFILEPICT structure to scale a picture. If hdcRef is NULL, Windows will use resolution data for the current output device. If lpmfp is NULL, Windows uses a default mapping mode of MM_ANISOTROPIC and scales the picture to fit the entire device surface.

When the application no longer needs the enhanced metafile handle, it should free the handle by calling the DeleteEnhMetaFile function.

The handle returned by this function can be used with other enhanced metafile calls.

If the reference device is not identical to the device in which the metafile is originally created, some GDI functions which use device units may not draw correctly.

See Also

METAFILEPICT, DeleteEnhMetaFile, GetWinMetaFileBits, PlayEnhMetaFile