load image control from emf in a byte array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

Can anybody tell me how to load an Access Image control with an emf in an
in-memory byte array?

I am building an interface between an Access 2K application and a SQL
Reporting Service.

I have a byte array coming from the webservice that I am inserting into an
Access report. Currently, I am saving the byte array to a temporary emf file
on disk using an ADODB.Stream and then setting the .Picture property of the
image control to the file name. I would like to use the byte array to load
the .PictureData property directly.

From Stephen Lebans' excellent site, I have learned that the difference
between my byte array and a byte array that would be a valid PictureData
property is two long integer values, the first containing CF_ENHMETAFILE (14)
and the second containing a handle for the in-memory metafile. Comparing the
output of the PictureData property to the byte array from the webservice, I
can see that this really is the case.

It appears that I can generate the metafile handle with SetEnhMetaFileBits
from the GDI32 API. But I am stumbling on how to make this
addition/translation to my byte array.

It seems like I am so close. Can anybody help me go the rest of the way?

Thanks,
Tim Bailey
 
Hi Tim,
Just write ZERO's for the Memory EMF handle. Access creates and uses this
hEMF at runtime by calling the SetEnhMetaFileBits API against the EMF data
that follows the 8 byte CF_ENHMETAFILE structure contained in the
PictureData prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thank you , Stephen!

I was making that way too hard. And thank you so much for all the fantastic
information on your website.

Tim Bailey
 
Back
Top