copying graphical data via enhanced meta file


this article was contributed by oliver eichler.

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 more’s 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 randy’s code. and it's working with word 7.0. tested printing, too. :)

have fun

last updated: 11 april 1998