CloseMetaFile

2.x

  HMETAFILE CloseMetaFile(hdc)    
  HDC hdc; /* handle of device context */

The CloseMetaFile function closes a metafile device context and creates a handle of a metafile. An application can use this handle to play the metafile.

Parameters

hdc

Identifies the metafile device context to be closed.

Return Value

The return value is the handle of the metafile if the function is successful. Otherwise, it is NULL.

Comments

If a metafile handle created by using the CloseMetaFile function is no longer needed, you should remove it (using the DeleteMetaFile function).

Example

The following example creates a device-context handle of a memory metafile, draws a line in the device context, retrieves a handle of the metafile, plays the metafile, and finally deletes the metafile.

HDC hdcMeta;
HMETAFILE hmf;

hdcMeta = CreateMetaFile(NULL);
MoveTo(hdcMeta, 10, 10);
LineTo(hdcMeta, 100, 100);
hmf = CloseMetaFile(hdcMeta);
PlayMetaFile(hdc, hmf);
DeleteMetaFile(hmf);

See Also

CreateMetaFile, DeleteMetaFile, PlayMetaFile