HDC CreateMetaFile(lpszFile) | |||||
LPCSTR lpszFile; | /* address of metafile name | */ |
The CreateMetaFile function creates a metafile device context.
lpszFile
Points to a null-terminated string that specifies the MS-DOS filename of the metafile to create. If this parameter is NULL, a device context for a memory metafile is returned.
The return value is the handle of the metafile device context if the function is successful. Otherwise, it is NULL.
When it has finished using a metafile device context created by CreateMetaFile, an application should close it by using the CloseMetaFile function.
The following example uses the CreateMetaFile function to create the handle of a device context for a memory metafile, draws a line in that device context, retrieves a handle of the metafile by calling the CloseMetaFile function, plays the metafile by using the PlayMetaFile function, and finally deletes the metafile by using the DeleteMetaFile function:
HDC hdcMeta;
HMETAFILE hmf;
hdcMeta = CreateMetaFile(NULL);
MoveTo(hdcMeta, 10, 10);
LineTo(hdcMeta, 100, 100);
hmf = CloseMetaFile(hdcMeta);
PlayMetaFile(hdc, hmf);
DeleteMetaFile(hmf);