Solved

How to create Metafile?

Posted on 1999-01-06
2
715 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

13 Experts available now in Live!

Get 1:1 Help Now