CreateMetaFile on Win7 64bit
-
I have test code that embeds a bitmap in a WMF metafile and creates a memory DC for that purpose. The code works fine on XP but fails on Windows7 64bit. The minimum sniplet to recreate the problem is:
HDC hDC = ::CreateMetaFile(\_T("test.wmf")); HDC memDC = ::CreateCompatibleDC(hDC); \_ASSERTE(memDC != NULL); ::DeleteDC(memDC); HMETAFILE hMeta = ::CloseMetaFile(hDC); ::DeleteMetaFile(hMeta);
CreateCompatibleDC fails and GetLastError returns 183. Is the creation of WMF files no longer supported on Windows7? The corresponding CreateEnhMetaFile method works fine. Thanks Carsten
-
I have test code that embeds a bitmap in a WMF metafile and creates a memory DC for that purpose. The code works fine on XP but fails on Windows7 64bit. The minimum sniplet to recreate the problem is:
HDC hDC = ::CreateMetaFile(\_T("test.wmf")); HDC memDC = ::CreateCompatibleDC(hDC); \_ASSERTE(memDC != NULL); ::DeleteDC(memDC); HMETAFILE hMeta = ::CloseMetaFile(hDC); ::DeleteMetaFile(hMeta);
CreateCompatibleDC fails and GetLastError returns 183. Is the creation of WMF files no longer supported on Windows7? The corresponding CreateEnhMetaFile method works fine. Thanks Carsten
Error 183 means "File already exists". If I remember correctly, CreateMetaFile was still around only for backwards compatibility with older Windows Metafiles. I think it was replaced by CreateEnhMetaFile some time ago.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Error 183 means "File already exists". If I remember correctly, CreateMetaFile was still around only for backwards compatibility with older Windows Metafiles. I think it was replaced by CreateEnhMetaFile some time ago.
A guide to posting questions on CodeProject[^]
Dave KreskowiakHi Dave, but why would "CreateCompatibleDC" return "File already exists"? The method "CreateMetaFile", that actually creates the file, completes successfully. I understand that CreateEnhMetaFile exists, but need to be able to create WMF file legacy reasons. Regards Carsten