Solved

How to create Metafile?

Posted on 1999-01-06
2
727 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum28 challenge 31 117
MaxSpan challenge 9 124
Change to event 1 129
Remove Password Protection from pdf (with password) using an command line executable 5 81
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.

749 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