A Windows metafile contains a sequence of GDI commands that can be replayed to create a desired image or text.
To implement a Windows metafile, first create a CMetaFileDC object.
You create a CMetaFileDC in two steps. First, call the constructor CMetaFileDC to construct the CMetaFileDC object, then call the Create member function, which creates a Windows metafile device context and attaches it to the CMetaFileDC object.
After the CMetaFileDC object is created, send a sequence of CDC GDI commands to the metafile device context. Use only those GDI commands that create output, such as MoveTo and LineTo.
Then call the Close member function, which closes the metafile device context and returns a metafile handle. Use the CMetaFile destructor to destroy the CMetaFile object.
CDC::PlayMetaFile can then use the metafile handle to play the metafile repeatedly, and the metafile can also be manipulated by Windows functions such as CopyMetaFile, which copies a metafile to disk.
When the metafile is no longer needed, delete it from memory with the DeleteMetaFile Windows function.
CDC