How to product a EMF file thanks 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面的代码片断产生一个图片大小为(800, 600)象素, 包括一个蓝色边框, 红色填充, 尺寸为(100, 100, 700, 500)象素单位矩形的Enhanced meta file: CFileDialog dlg(FALSE, "wmf", "test.wmf"); if (dlg.DoModal()) { CString strFileName = dlg.GetPathName(); CDC *pDC = GetDC(); CRect rcBox(0, 0, 800, 600); rcBox.left = rcBox.left * pDC->GetDeviceCaps(HORZSIZE) * 100 / pDC->GetDeviceCaps(HORZRES); rcBox.top = rcBox.top * pDC->GetDeviceCaps(VERTSIZE) * 100 / pDC->GetDeviceCaps(VERTRES); rcBox.right = rcBox.right * pDC->GetDeviceCaps(HORZSIZE) * 100 / pDC->GetDeviceCaps(HORZRES); rcBox.bottom = rcBox.bottom * pDC->GetDeviceCaps(VERTSIZE) * 100 / pDC->GetDeviceCaps(VERTRES); CDC *pMetaDC = CDC::FromHandle(CreateEnhMetaFile(pDC->m_hDC, strFileName, &rcBox, NULL)); if (pMetaDC) { int nOldMap = pMetaDC->SetMapMode(MM_LOENGLISH); CRect rc(100, 100, 700, 500); pMetaDC->DPtoLP(&rc); CPen pen(PS_SOLID, 2, RGB(0, 0, 255)); CBrush brush(RGB(255, 0, 0)); CPen *pOldPen = (CPen *)pMetaDC->SelectObject(&pen); CBrush *pOldBrush = (CBrush *)pMetaDC->SelectObject(&brush); pMetaDC->Rectangle(&rc); pMetaDC->SelectObject(pOldPen); pMetaDC->SelectObject(pOldBrush); pMetaDC->SetMapMode(nOldMap); HENHMETAFILE hMetaFile = CloseEnhMetaFile(pMetaDC->Detach()); if (hMetaFile) { DeleteEnhMetaFile(hMetaFile); } } else { AfxMessageBox("Failed to create meta file ."); } ReleaseDC(pDC); } vc工程加入已有的类出现的问题 VC GDI+如何把几幅图片合成一张GIF啊 很好奇软件的自动升级是怎么弄的 急!为什么将.ico文件中的图形粘贴到工具栏中后运行程序发现工具栏中的图片色彩失真??? 请好心人帮助! 各位winddk在那下载,这个主要做什么用 调试程序遇到的一个小问题,大虾帮帮忙啊!! 在线!急问,获得My document路径的函数是什么,我一时想不起来了! 如何时间按钮的右击事件? 如何将unsigned char类型的数据赋给一个字符串类型的数据? 关于SOCKET的多线程问题 一个很小但很难解决的问题?
{
CString strFileName = dlg.GetPathName();
CDC *pDC = GetDC(); CRect rcBox(0, 0, 800, 600);
rcBox.left = rcBox.left * pDC->GetDeviceCaps(HORZSIZE) * 100 / pDC->GetDeviceCaps(HORZRES);
rcBox.top = rcBox.top * pDC->GetDeviceCaps(VERTSIZE) * 100 / pDC->GetDeviceCaps(VERTRES);
rcBox.right = rcBox.right * pDC->GetDeviceCaps(HORZSIZE) * 100 / pDC->GetDeviceCaps(HORZRES);
rcBox.bottom = rcBox.bottom * pDC->GetDeviceCaps(VERTSIZE) * 100 / pDC->GetDeviceCaps(VERTRES); CDC *pMetaDC = CDC::FromHandle(CreateEnhMetaFile(pDC->m_hDC, strFileName, &rcBox, NULL));
if (pMetaDC)
{
int nOldMap = pMetaDC->SetMapMode(MM_LOENGLISH);
CRect rc(100, 100, 700, 500);
pMetaDC->DPtoLP(&rc);
CPen pen(PS_SOLID, 2, RGB(0, 0, 255));
CBrush brush(RGB(255, 0, 0)); CPen *pOldPen = (CPen *)pMetaDC->SelectObject(&pen);
CBrush *pOldBrush = (CBrush *)pMetaDC->SelectObject(&brush); pMetaDC->Rectangle(&rc); pMetaDC->SelectObject(pOldPen);
pMetaDC->SelectObject(pOldBrush);
pMetaDC->SetMapMode(nOldMap); HENHMETAFILE hMetaFile = CloseEnhMetaFile(pMetaDC->Detach());
if (hMetaFile)
{
DeleteEnhMetaFile(hMetaFile);
}
}
else
{
AfxMessageBox("Failed to create meta file .");
} ReleaseDC(pDC);
}