Copying Graphical Data via Enhanced Meta File

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();
	//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
	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


  • Meta-File is not created!

    Posted by Legacy on 04/07/2003 12:00am

    Originally posted by: Matthias Beck

    I tried what you wrote, but it doesn�t work.
    The application doesn�t create any .emf file.
    What can I do? Shall I copy the Meta File like this?

    CopyEnhMetaFile(hMF, "CopiedMeta-File.emf" );

    or play the Meta-File???

    pDC->PlayMetaFile (hMF, rechteck);

    don�t know what to do...

    Thanks in advance!!!

  • how to copy selected region in graph

    Posted by Legacy on 08/15/2002 12:00am

    Originally posted by: jing zhang

    Hi there,

    I have a problem about copying selected region in graph. I have a
    scrollview to show my graph, which has zoom in/out function. When I
    zoom in, the whole graph is redrawn in total scroll size, but only
    region of interested will be shown in view client area. Now, I only
    want to copy the zoom-in part in client area, not the total scroll
    size, how can I do? I use CMetaFileDC for copying, and also try to use
    SetViewportExt and SetViewportOrg to set the position, but they don't
    work. Any sample code will be very appreciated.

    Thank you very much!


  • Is there some changes in OfficeXP for handling enhance metafile ?

    Posted by Legacy on 01/23/2002 12:00am

    Originally posted by: Sapto Priyono

    I have copied the object of OfficeXP (shapes in Power Point) and with COleDataObject, I get their enhance metafile. I enumerate this enhance metafile to be many enhance metarecords. In Office'97 and Office 2000, the position and demension of this enhance metafile (rclBounds, szlDevice,xDest,cxDest,yDest,cyDest etc in enhance metarecords) are correct, but not correct in OfficeXP. I use the OS of Windows 2000 Profesional. Is there some changes in OfficeXP for handling enhance metafile ? Thank's.

  • How can I save a bitmap file to disk (bmp, gif or jpg) from an Enhanced Metafile in Clipboard?

    Posted by Legacy on 01/17/2002 12:00am

    Originally posted by: Sergi Balaguer

    I'm trying to retrieve data from Clipboard that is in Enhanced Metafile format. I have already achieved this. But I want to save a Bitmap file (BMP, GIF, or JPG) from this EMF data in Clipboard to disk. How can I do this?


  • not working inside an ATL control !

    Posted by Legacy on 01/07/2002 12:00am

    Originally posted by: shyamal

    I tried the same inside an ATL ActiveX control.. Doesnt seem to be working :(

  • Problems with SetTextAlign

    Posted by Legacy on 12/15/1999 12:00am

    Originally posted by: Cathy Grimes

    When calling CDC:SetTextAlign to align text, the old alignment should be returned. However, when calling this function when the device context is a metafile, a random number is returned. If the old text alignment is used to reset the text alignment, this can have the effect of showing misaligned text on the clipboard or pasted image. I recommend that you do not used the old text alignment but explicitly set the alignment that you require.

    Do not rely on this code

    UINT old_align = m_pDC->SetTextAlign( TA_CENTER | TA_TOP );

    m_pDC->SetTextAlign( old_align );

    This is safer

    UINT old_align = m_pDC->SetTextAlign( TA_CENTER | TA_TOP );

    m_pDC->SetTextAlign( TA_LEFT | TA_TOP );

  • Works well!

    Posted by Legacy on 09/01/1999 12:00am

    Originally posted by: Pascal Bertolino

    Thank you for this code, it's straightforward and it works well. Now, we are waiting for a paste snippet... :-)


  • Works well!

    Posted by Legacy on 09/01/1999 12:00am

    Originally posted by: Pascal Bertolino

    Thank you for this code, it's straightforward and it works well. Now, we are waiting for a paste snippet... :-)


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Complex hybrid environments can make it difficult to track interdependencies, increasing the risk of disrupting critical business services. In this white paper by EMA, you'll learn how application discovery and dependency mapping can help you: Meet granular targets for availability, cost, and time-to-revenue for cloud services. Accelerate mean time to repair (MTTR) while communicating better with stakeholders. Manage even the most complex hybrid environments more efficiently and effectively Understand the …

  • Rocket Mobile® for IBM i is an enterprise mobile application development and deployment platform for customers who rely on the IBM i system. Rocket Mobile for IBM i enables customers to leave proven applications in-place and rapidly repurpose them into new managed and secure mobile applications. Fast, easy creation of mobile, web, and hybrid mobile applications that deploy to any iOS, Android, or Windows mobile phone or tablet Built-in integration for seamless repurposing of existing IBM i applications …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date