Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PlayMetaFile in a MemoryDC

Posted on 1997-05-05
3
Medium Priority
?
591 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 150 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

660 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