Place a enhanced metafile on the clipboard (uses OLE)
Posted
by Randy More
on August 6th, 1998
#include < afxole.h >
and do the following during initialization
OleInitialize(NULL);
(2) The following places a metafile copy of a view on the clipboard. It can be easily modified to work with any CWnd that draws to a CDC.
void CMyView::OnEditCopyWmf()
{
tagSTGMEDIUM * data;
CClientDC dcRef( this );
data = new tagSTGMEDIUM;
CMetaFileDC * dcMeta;
dcMeta = new CMetaFileDC();
COleDataSource* pData = new COleDataSource;
CRect lmbr;
GetClientRect(lmbr);
//replace "ImageName" with a description of this image
dcMeta->CreateEnhanced(&dcRef, NULL, NULL,"ImageName\0Copy\0\0" );
dcMeta->SetMapMode(MM_TEXT);
//actually draw to the device context
OnDraw(dcMeta);
//done drawing
data->tymed = TYMED_ENHMF;
data->hEnhMetaFile = dcMeta->CloseEnhanced();
pData->CacheData( CF_ENHMETAFILE, data );
pData->SetClipboard();
delete dcMeta;
delete data;
}

Comments
How to send the text in a dialog box to clipboard
Posted by Legacy on 10/24/2002 12:00amOriginally posted by: Vidya Rajkumar
I have some 4 edit boxes in a dialog.
For eg.
Name Vidya
Age 23
Sex Female
occupation S/W Engineer
Assume that these are the controls in a single dialog box.
What i want is,on just pressing a button in toolbar,the data has to be sent to the clipboard ..Note that the nothing is selected or focussed.
The data in the clipboard should be in the below format
Name Vidya
Age 23
Sex Female
occupation S/W Engineer
ReplyHow is it?
oops
Posted by Legacy on 10/21/2002 12:00amOriginally posted by: W. J. Heitler
Sorry, I've just noticed that the SetAtribDC modification was incorported in the earlier comment.
ReplyIt's not immediately obvious how to withdraw a comment, but if someone tells me how I'll pull this one and the previous.
reading attributes like text height etc
Posted by Legacy on 10/21/2002 12:00amOriginally posted by: W. J. Heitler
ReplyAdapted solution with correct rectangle dimensions and some simplification
Posted by Legacy on 05/08/2002 12:00amOriginally posted by: Wim
ReplyImages do not render as expected when pasted to MS Word or MS PowerPoint
Posted by Legacy on 12/09/2001 12:00amOriginally posted by: John W. Blakely
ReplyHow do I edit enhance metafile from clipboard ?
Posted by Legacy on 08/21/2001 12:00amOriginally posted by: Sapto Priyono
I have a enhance metafile which is copied from the shape of Power Point object, but after I play with PlayEnhMetaFile, this enhmetafile has uncorrect displaying (fontsize is not correct, appear bullet in the first character). Why and how do I edit this enhmetafile ?. I have edited it's enhmetaheader, but no influence for the displaying.
ReplyHow one can render metafile image from dialog control?
Posted by Legacy on 04/09/2001 12:00amOriginally posted by: Michael
Replyduplicating Alt+PrtScrn
Posted by Legacy on 02/09/2000 12:00amOriginally posted by: P. McLaughlin
ReplyHow Can I use it For CFrameWnd Derieved Classes
Posted by Legacy on 05/30/1999 12:00amOriginally posted by: A.Qudus Abbasi
Reply