The code below is copying graphical data via enhanced meta file to
any application. Even to WinWord 7.0 which makes it different to
Randy Mores code. It is placed into an appropriate function of a
class derived from 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;
Altogether it is a pretty straight forward solution as suggested by the
help documents provided with VC++ making it a good alternative to Randys
code. And it’s working with Word 7.0. Tested printing, too. 🙂
Have fun
Last updated: 11 April 1998