我写了一段程序(VC6.0)在win2000下没有任何问题,但放在win98下80%的文件能打开,20%的打开后一片空白,后跟踪发现WMF的文件句柄已得到,但pDC->PlayMetalFile执行也不出错,但显示一片空白???问题是同一段代码,有的WMF文件却显示的好的,奇怪,难道PlayMetalFile在win2000和win98下有区别?请有经验的人指点!!!
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
HENHMETAFILE hEnhMeta = pDoc->GethEnhMeta();
if(hEnhMeta == NULL)
{
TRACE("error metafile!\n");
return;
} CRect rect;
GetClientRect(&rect);

pDC->PlayMetaFile( hEnhMeta, rect );
}class CTestDoc : public CDocument
{
...
// Attributes
public:
HENHMETAFILE m_hEnhMeta;// Operations
public:
HENHMETAFILE GethEnhMeta(){return m_hEnhMeta;};
....
}BOOL CTestDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;

// TODO: Add your specialized creation code here
CFileStatus rStatus;

if (CFile::GetStatus(lpszPathName,rStatus) == 0)
{
CString tempstr;
tempstr.Format("%s文件不存在!",lpszPathName);
AfxMessageBox(tempstr);
return FALSE;
} m_hEnhMeta = ReadEnhMetaFile( (LPSTR)(LPCSTR)lpszPathName );
         //此处读出的handle有效的,跟踪看的!!!
         if( m_hEnhMeta == NULL )
{
    AfxMessageBox( "WMF MetaFile文件格式不符!");
    return FALSE;
} /////////Reload zoomdlg content!
CFrameWnd *pFrame = (CFrameWnd *)pApp->m_pMainWnd;
CTjcnDiagramView *pView = (CTjcnDiagramView *)(pFrame->GetActiveView());
return TRUE;
}

解决方案 »

  1.   

    你有msn或者别的吗。。我也在开发wmf文件相关工作。。遇到些问题咱们交流一下吧!
    我的[email protected]
      

  2.   

    我找了个别的控件打开了,但又有个问题,是不是WMF的显示特别占内存和资源呀?我快速打开20多个WMF文件,后面的WMF文件就不显示了,但我将显卡改为16位就能多打开(原来为32位真彩),同时看到内存很快就耗尽了,但我查了程序,绝对没有内存泄露,所有的资源和文件句柄一关闭就释放的!图形真难查呀!!!