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
Solved

How to create Metafile?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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
maxBlock challenge 30 142
if loop in java 3 152
Excel file not created as expected 7 79
I could not set window to top 4 20
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 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