下面代码拷贝通过元文件拷贝图像数据到任何应用程序,其可以放置在CView派生类的函数中。
CMetaFileDC * m_pMetaDC = new CMetaFileDC(); m_pMetaDC->CreateEnhanced(GetDC(),NULL,NULL,"whatever"); //draw meta file //do what ever you want to do: bitmaps, lines, text... //close meta file dc and prepare for clipboard; HENHMETAFILE hMF = m_pMetaDC->CloseEnhanced(); //copy to clipboard OpenClipboard(); EmptyClipboard(); ::SetClipboardData(CF_ENHMETAFILE,hMF); CloseClipboard(); //DeleteMetaFile(hMF); delete m_pMetaDC;