Solved

MFC MDI MetaFiles, EnhancedMetaFiles

Posted on 1998-05-09
2
404 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
notReplace  challenge 53 116
maven archtype selection in eclipse 1 53
modThree challenge 4 79
My project did see openJDK that I installed. What could be the problem 7 123
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

18 Experts available now in Live!

Get 1:1 Help Now