Check out this thread (I haven't tested the solution) - convert-wmf-file-to-emf-file-with-setwinmetafilebits-api-in-c
How to read an old Windows Meta File?
I am reading Enhanced Meta Files with ::GetEnhMetaFile( pszFilename ) which returns a HENHMETAFILE handle.
But I want to read the old fashioned Windows Meta Files too. Can anyone tell me how to do this???
I am going round in circles with the docuemtation.
GetMetaFile
The docs tell me that ::GetMetaFile( pszFilename ) does the job, but also that "GetMetaFile is no longer available for use as of Windows 2000. Instead, use GetEnhMetaFile".
GetEnhMetaFile
The documentation for GetEnhMetaFile says:
"A Windows-format metafile must be converted to the enhanced format before it can be processed by the GetEnhMetaFile function. To convert the file, use the SetWinMetaFileBits function."
SetWinMetaFileBits
So I look at SetWinMetaFileBits(). IT has a number of arguments, none of which is a file name but including "A pointer to a buffer that contains the Windows-format metafile data. (It is assumed that the data was obtained by using the GetMetaFileBitsEx or GetWinMetaFileBits function.)"
Now SetWinMetaFileBits() returns an HENMETAFILE handle which is great, but if I have that, then I don't need GetEnhMetaFile() so what was that about? Furthermore
GetWinMetaFileBits
takes an HENHMETAFILE as an argument, and fills in a buffer with Win Meta File format data; But haven't got an HENHMETAFILE.
GetMetaFileBitsEx
fills in a data buffer in WMF format, if you have an HMETAFILE. But to get an HMETAFILE from my file on disk, the obvious way is to use GetMetaFile() but...
There's a hole in my bucket?
Dave
2 additional answers
Sort by: Most helpful
-
David Lowndes 4,721 Reputation points
2020-11-17T17:53:51.677+00:00 Gdiplus seems to be able to load a WMF file.
>
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL );Metafile gdimf( Path to a WMF file );
GdiplusShutdown( gdiplusToken ); -
Castorix31 86,311 Reputation points
2020-11-17T18:44:03.907+00:00 There are several ways to load/display WMF
A simple one is with OleLoadPicture