We help IT Professionals succeed at work.
Get Started

Getting a hMF (heMF) for a .wmf in 32-bit VB (4, 5, or 6)

caraf_g
caraf_g asked
on
824 Views
Last Modified: 2012-05-04
(This should work on VB6 and VB5, and it would be nice if it would also work on 32-bit VB4)

I am trying to "open" a .wmf file in a 32-bit VB application in order to get a metafile handle (heMF or hMF), which I can then use to "play" the metafile into a device context with the PlayEnhMetaFile API. I know how to do that bit, and if I only had an .emf file instead of a .wmf file, this would be very simple: Use the GetEnhMetaFile API to get the heMF from the .emf file.

Alas, the file I have is a .wmf file. To get a handle for a .wmf file, you needed to use the GetMetaFile API. Alas, this API became obsolete in 32-bit.

The GetEnhMetaFile API is not suitable for .wmf files.

From reading the MSDN documentation I reckon it must be possible though to take an ordinary .wmf file, somehow process it, and eventually come up with a 32-bit metafile handle (heMF) which I can then use to play the metafile
into a device context.

This is giving me headaches...

I read the MSDN information, and even though (I think) I have a vague idea on what APIs to use, I'm severely hampered: I do not know C or C++. The documentation in MSDN is limited to "This is the API function and this is how it's declared in C++". It doesn't tell you HOW to use it. I have to use this from VB...

I would therefore appreciate a nice self-contained code example in VB on how to take a .wmf and end up with a valid hMF in a 32 bit VB application

Many thanks


Pino Carafa
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE