Solved

PlayMetaFile in a MemoryDC

Posted on 1997-05-05
3
567 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
  • 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
Process filename extension 3 207
pre4 challenge 19 110
post4 challenge 28 113
Authenticate using sesu from script 7 106
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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

680 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