Given a Windows handle to an Enhanced Metafile, how can I convert it into RTF code which displays this metafile, e.g. when it is handed over to the TextRTF property of a Rich Text Box control, or copied to Clipboard and pasted into Word? The RTF (V1.5) specification tells me to use the \pict and \emfblip control words, and to supply the picture data in hexadecimal format. The spec does not tell me how to get those picture data. For Bitmaps, the spec suggests to use the GDI "GetBitmapBits" function. By analogy, I thought I might use the GDI "GetEnhMetafileBits" function for an Enhanced Metafile. But it does not work. This is my RTF code:
data as hexadecimal string
The Rich Text Box control can be made to paste Enhanced Metafiles (by pressing Ctl-v at runtime), so by inspecting its TextRTF property it is possible to see what code it creates. Unexpectedly, it uses the \wmetafile8 keyword instead of \emfblip, and it produces hexadecimal data which include the result of GetEnhMetafileBits (converted to hexadecimal string), but has additional bytes before and after those. I'm puzzled.
Can anybody help?