?
Solved

How to create Metafile?

Posted on 1999-01-06
2
Medium Priority
?
744 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 330 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

840 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