Solved

How to create Metafile?

Posted on 1999-01-06
2
718 Views
Last Modified: 2013-11-20
I'm using VC++5.0 and want to create a metafile from the complete (what is visible and what you have to scroll to) client area of a window.  Should I use CreateEnhMetaFile to create a DC, WM_PRINTCLIENT to have the window draw its client area to the DC, and then PlayEnhMetaFile to write out?
0
Comment
Question by:borghard
2 Comments
 
LVL 1

Accepted Solution

by:
dd_b earned 110 total points
ID: 1327315
yes,  u can use this function

HDC CreateEnhMetaFile( HDC hdcRef, // handle to a reference                                                                  device context
                                        LPCTSTR lpFilename, // pointer to a                                                                            //filename string
                                          CONST RECT *lpRect,
                                          LPCTSTR lpDescription );

but remember Windows uses the reference device identified by the hdcRef parameter to record the resolution and units of the device on which a picture originally appeared. If the hdcRef parameter is NULL, it uses the current display device for reference. so the content will not transfered.

the size of your printing area is known to you.

after getting the DC u can BitBlt all the content of client window to MetafileDC.

dc.BitBlt();

0
 

Author Comment

by:borghard
ID: 1327316
Thanks!  I found an example in "Creating an Enhance Metafile" but I don't see how I should declare hdcRef properly before using the application window as the reference DC.
Trying something like this:
      hdcRef = GetDC();
      int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE);
      int iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE);
      int iWidthPels = GetDeviceCaps(hdcRef, HORZRES);
      int iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
      GetClientRect(&rect);
              rect.left = (rect.left * iWidthMM * 100)/iWidthPels;
              rect.top = (rect.top * iHeightMM * 100)/iHeightPels;
              rect.right = (rect.right * iiWidthMM * 100)/iWidthPels;
              rect.bottom = (rect.bottom * iHeightMM * 100)/iHeightPels;
              LPTSTR lpstrFile = "TestString";
              LPTSTR szDescription = "TestSize";
              hdcMeta = CreateEnhMetaFile(NULL, (LPTSTR) lpstrFile, &rect,
                     (LPTSTR) szDescription);

Am I even close?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 195
Strange date stored 22 118
modThree challenge 4 88
Updating statistics with error notification email in SQL server 4 94
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

816 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

8 Experts available now in Live!

Get 1:1 Help Now