April 8th, 1999, 11:53 AM
I am creating Windows Metafiles, which must be read properly by Word 97.
(yes, yes, I know WMF is an obsolete format -- tell that to my management!)
I create the WMF as an Aldus placeable metafile, as follows:
int nxExt = 0,
nyExt = 0;
if (m_BasicGraphs.GetSize() > 0)
m_BasicGraphs.GetAt(0)->GraphSize(GDI_UNITS,&nxExt,&nyExt);
nxExt += 10; //A small fudge-factor
nyExt += 10;
pdcMeta->SetMapMode (MM_ANISOTROPIC);
pdcMeta->SetWindowExt (nxExt,-nyExt);
pdcMeta->SetViewportExt(nxExt, nyExt);
pdcMeta->SetViewportOrg(0,0);
DrawAllGraphs((CDC*)pdcMeta,TRUE);
//Get the metafile handle
HMETAFILE hmf = pdcMeta->Close();
//Create the APM header
int nWidth,nHeight;
if (pGr == NULL)
return FALSE;
pGr->GraphSize(GDI_UNITS,&nWidth,&nHeight);
m_apmHdr.key = APMHEADER_KEY;
m_apmHdr.hmf = NULL;
m_apmHdr.inch = PTS_PER_INCH;
m_apmHdr.reserved = 0;
m_apmHdr.bbox.Left = 0;
m_apmHdr.bbox.Top = 0;
m_apmHdr.bbox.Right = (short)nWidth +10;
m_apmHdr.bbox.Bottom = (short)nHeight+10;
//Create the checksum
for (p = (WORD *)&(m_apmHdr), m_apmHdr.checksum = 0;
p < (WORD *)&(m_apmHdr.checksum);++p)
{
m_apmHdr.checksum ^= *p;
}
I then write the header and the metafile bits to disk.
Word is able to import the metafile and resize the metafile. However, if I try to edit it, Word "loses" the metafile -- the edit area is blank, and Word is unable to display it again, once I "close and return to document".
I am sure this has something to do with the mapping mode, and the fact that negative y is downward. I tried cresating the metafile using MM_HIENGLISH.
I could then edit the metafile, but not resize it.
Has anyone out there created WMF's successfully, and if so, what creation method did you use?
Thanks,
Wes Rogers
(yes, yes, I know WMF is an obsolete format -- tell that to my management!)
I create the WMF as an Aldus placeable metafile, as follows:
int nxExt = 0,
nyExt = 0;
if (m_BasicGraphs.GetSize() > 0)
m_BasicGraphs.GetAt(0)->GraphSize(GDI_UNITS,&nxExt,&nyExt);
nxExt += 10; //A small fudge-factor
nyExt += 10;
pdcMeta->SetMapMode (MM_ANISOTROPIC);
pdcMeta->SetWindowExt (nxExt,-nyExt);
pdcMeta->SetViewportExt(nxExt, nyExt);
pdcMeta->SetViewportOrg(0,0);
DrawAllGraphs((CDC*)pdcMeta,TRUE);
//Get the metafile handle
HMETAFILE hmf = pdcMeta->Close();
//Create the APM header
int nWidth,nHeight;
if (pGr == NULL)
return FALSE;
pGr->GraphSize(GDI_UNITS,&nWidth,&nHeight);
m_apmHdr.key = APMHEADER_KEY;
m_apmHdr.hmf = NULL;
m_apmHdr.inch = PTS_PER_INCH;
m_apmHdr.reserved = 0;
m_apmHdr.bbox.Left = 0;
m_apmHdr.bbox.Top = 0;
m_apmHdr.bbox.Right = (short)nWidth +10;
m_apmHdr.bbox.Bottom = (short)nHeight+10;
//Create the checksum
for (p = (WORD *)&(m_apmHdr), m_apmHdr.checksum = 0;
p < (WORD *)&(m_apmHdr.checksum);++p)
{
m_apmHdr.checksum ^= *p;
}
I then write the header and the metafile bits to disk.
Word is able to import the metafile and resize the metafile. However, if I try to edit it, Word "loses" the metafile -- the edit area is blank, and Word is unable to display it again, once I "close and return to document".
I am sure this has something to do with the mapping mode, and the fact that negative y is downward. I tried cresating the metafile using MM_HIENGLISH.
I could then edit the metafile, but not resize it.
Has anyone out there created WMF's successfully, and if so, what creation method did you use?
Thanks,
Wes Rogers