[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Metafiles
From: |
Tomas Gudmundsson |
Subject: |
Metafiles |
Date: |
Wed, 11 Dec 1996 16:09:59 +0000 |
Dear Standa,
I have discovered what causes the "Out of memory" problem in Windows 95 when
you copy a metafile to the clipboard : You should not call DeleteEnhMetafile().
The code I am using is attached.
There is however another problem, Word does not recognize the size of the
graphics under Windows 95. This works under NT. I do not have any solution to
this problem. It is not too serious for time series, etc, but worse for
networks where the aspect ratio is fixed. When you copy and paste metafiles
between documents in Word, the size is maintained. It seems as if Word adds
some information to the header of the file. You can examine the file using the
MFEdit example.
Best Regards
Tomas
//-------------------------------------------------------------------------------------------------
void CTSEditGraphView::CopyMetaFileToClipboard()
{
CDC* pDC = GetDC();
// Find pixels per millimeters
double horzpixpermm, vertpixpermm;
horzpixpermm = (double)pDC->GetDeviceCaps(HORZRES) /
(double)pDC->GetDeviceCaps(HORZSIZE);
vertpixpermm = (double)pDC->GetDeviceCaps(VERTRES) /
(double)pDC->GetDeviceCaps(VERTSIZE);
// Find size of client area in millimeters
CRect ClientArea;
GetClientRect(&ClientArea);
double widthmm, heightmm;
widthmm = (double)(ClientArea.right - ClientArea.left) / horzpixpermm;
heightmm = (double)(ClientArea.bottom - ClientArea.top) / vertpixpermm;
// Create metafile and copy to clipboard
CMetaFileDC MFDC;
CRect Bounds(0,0,(int)(100.0 * widthmm),(int)(100.0 * heightmm));
if (!MFDC.CreateEnhanced(pDC,NULL,&Bounds,"Time Series Editor\0Time
Series\0\0"))
{
MessageBox("Could not create metafile");
return;
}
MFDC.SetAttribDC(pDC->m_hDC);
OnDraw(&MFDC);
HENHMETAFILE hMF = MFDC.CloseEnhanced();
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_ENHMETAFILE,hMF);
CloseClipboard();
} // End CTSEditGraphView::CopyMetaFileToClipboard()
//-------------------------------------------------------------------------------------------------
- Metafiles,
Tomas Gudmundsson <=