Solved

MFC MDI MetaFiles, EnhancedMetaFiles

Posted on 1998-05-09
2
402 Views
Last Modified: 2013-11-20
Visual C++ 5.0, MDI application:

I tried to paint my window to a CMetaFileDC class, a regular one doesn't work, so I created an Enhanced MetaFile. The problem is that the texts are not saved. On the contrary the graphics are OK, but the text cannot be seen in the result file when I open it. The texts are written with the DrawText(...) function.

- How to fix the text problem: my code is:
mfdc.CreateEnhanced(NULL, "c:\\gir.emf", NULL, "GioGraph\0Graph\0\0" );//creating
pDoc->Data.DrawGraph(&mfdc, MaxSize, DG_METAFILE);//drawing
HENHMETAFILE hemf = mfdc.CloseEnhanced();//getting handle

- How to work with a regualar-not-enhanced MetaFile - my code is:
mfdc.Create("c:\\gir.wmf");//creating
pDoc->Data.DrawGraph(&mfdc, MaxSize, DG_METAFILE);//drawing
HMETAFILE hemf = mfdc.Close();//getting handle
0
Comment
Question by:giora
  • 2
2 Comments
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1308877
Can you post the code for pDoc->Data.DrawGraph() ?
0
 
LVL 4

Accepted Solution

by:
piano_boxer earned 100 total points
ID: 1308878
Try this code (It works for me in a very complex view drawing):


CDC* pDC = GetDC();
pDC->SetMapMode(MM_HIMETRIC);
CMetaFileDC dc;
if(dc.CreateEnhanced(pDC, "filename.emf", NULL, "Test\0File\0\0"))
{
    dc.SetMapMode(MM_HIMETRIC);
    dc.m_bPrinting = TRUE;
    dc.m_hAttribDC = pDC->m_hDC;
    OnDraw(&dc);  // Call normal drawing routine for the view
}

::DeleteEnhMetaFile(dc.CloseEnhanced());
ReleaseDC(pDC);

NOTE: You can change/remove the SetMapMode(MM_HIMETRIC) calls if you use a different mapping mode.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Window placement 17 64
How to convert MFC::CString to UTF8 wchar_t* 10 96
Path of Workbook 3 45
Sed question 2 48
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now