void CViewView::OnDraw(CDC* pDC)
{ HENHMETAFILE m_emf;
CRect r ;
GetClientRect(&r);
m_emf = GetEnhMetaFile(_T("c:\\a.emf"));
pDC->PlayMetaFile(m_emf,r);
}
我要在VIEW上显示一EMF图。可是这样写什么也形式!
谢谢了!
{ HENHMETAFILE m_emf;
CRect r ;
GetClientRect(&r);
m_emf = GetEnhMetaFile(_T("c:\\a.emf"));
pDC->PlayMetaFile(m_emf,r);
}
我要在VIEW上显示一EMF图。可是这样写什么也形式!
谢谢了!
==================================这一节描述了应用程序怎样打开一个存放于磁盘上的增强型元文件,并将元文件图像显示在窗口客户区的
方法。范例通过使用OpenFile对话框来让用户选择一个增强型元文件,并将选择的文件名发给GetEnhMetaFile()
函数,该函数返回一个标识该文件的句柄。这个句柄就可以传给PlayEnhMetaFile()函数来显示元文件图像。以下是范例代码:
LoadString(hInst, IDS_FILTERSTRING,
(LPSTR)szFilter, sizeof(szFilter));
/*
* Replace occurrences of '%' string separator
* with '\0'.
*/
for (i=0; szFilter[i]!='\0'; i++)
if (szFilter[i] == '%')
szFilter[i] = '\0';
LoadString(hInst, IDS_DEFEXTSTRING,
(LPSTR)szDefExt, sizeof(szFilter));
/*
* Use the OpenFilename common dialog box
* to obtain the desired filename.
*/
szFile[0] = '\0';
Ofn.lStructSize = sizeof(OPENFILENAME);
Ofn.hwndOwner = hWnd;
Ofn.lpstrFilter = szFilter;
Ofn.lpstrCustomFilter = (LPSTR)NULL;
Ofn.nMaxCustFilter = 0L;
Ofn.nFilterIndex = 1L;
Ofn.lpstrFile = szFile;
Ofn.nMaxFile = sizeof(szFile);
Ofn.lpstrFileTitle = szFileTitle;
Ofn.nMaxFileTitle = sizeof(szFileTitle);
Ofn.lpstrInitialDir = (LPSTR) NULL;
Ofn.lpstrTitle = (LPSTR)NULL;
Ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
Ofn.nFileOffset = 0;
Ofn.nFileExtension = 0;
Ofn.lpstrDefExt = szDefExt;
GetOpenFileName(&Ofn);
/* Open the metafile. */
hemf = GetEnhMetaFile(Ofn.lpstrFile);
/* Retrieve a handle to a window DC. */
hDC = GetDC(hWnd);
/* Retrieve the client rectangle dimensions. */
GetClientRect(hWnd, &rct);
/* Draw the picture. */
PlayEnhMetaFile(hDC, hemf, &rct);
/* Release the metafile handle. */
DeleteEnhMetaFile(hemf);
/* Release the window DC. */
ReleaseDC(hWnd, hDC);
copy的MSDN里的help