Solved

PlayMetaFile in a MemoryDC

Posted on 1997-05-05
3
572 Views
Last Modified: 2013-11-20
Hi,

I tried to play a Metafile into a compatible Memory DC with MFC. It did not work. Is it possible? And how can I do it?
0
Comment
Question by:lenord
[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
3 Comments
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301341
How you try do it? Can you show code?
0
 

Author Comment

by:lenord
ID: 1301342
Hi,

here is a part of the source code:
Thanks.


CBitmap * MetaBitmap;
CDC*      MetaDC;

if (MetaBitmap)
      delete MetaBitmap;
if (MetaMemDC)
      delete MetaMemDC;
            
// neue Bitmap erzeugen
MetaBitmap = new CBitmap;
if (!MetaBitmap->CreateCompatibleBitmap( pDC,
      (int)((BitmapSize.right-BitmapSize.left)),
      (int)((BitmapSize.bottom-BitmapSize.top)) ))
      return FALSE;

// neuen Memory DC erzeugen
MetaMemDC = new CDC;
if (!MetaMemDC->CreateCompatibleDC( pDC ) ||
      !MetaMemDC->SelectObject(MetaBitmap)            )
      return FALSE;
   
// Bitmap neu erzeugen
// Mapmode setzen
pDC->SetMapMode(MM_ANISOTROPIC);
// Viewport-Ausdehnung entsprechend der Bitmapgröße setzen
pDC->SetViewportExt( (int)((BitmapSize.right-BitmapSize.left)),
                 (int)((BitmapSize.bottom-BitmapSize.top)) );
      
// Metafile abspielen
if (!MetaMemDC->PlayMetaFile(MetaFile))
{                  
      TRACE("Fehler beim Abspielen des Metafiles");
      return FALSE;
}                          

// Bitmap anzeigen
      
if (!pDC->BitBlt(       DstRect.left,                  // Dest X-Pos
                    DstRect.top,                  // Dest Y-Pos
                   DstRect.right-DstRect.left,      // Dest Breite
                   DstRect.bottom-DstRect.top,      // Dest Höhe
                   MetaMemDC,                  // Source DC
                   DstRect.left,                  // Src X-Pos
                   DstRect.top,                  // Src Y-Pos
                   SRCCOPY )      )            // Modus
      return FALSE;                                     
return TRUE;

0
 
LVL 4

Accepted Solution

by:
AVaulin earned 50 total points
ID: 1301343
I see no errors. But I recently solved like your problem by this way: try move your code from "OnDraw" method to "OnPaint" (you must handle WM_PAINT message of course). In my case there was bitmap instead metafile and I saw no it until I did what I propose.
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
Shell script to login to remote m/c and execute commands 10 80
Annoying "thing" blocks my view 4 143
Not needed 13 133
JQuery serialize and unserialize 8 262
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…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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