Solved

PlayMetaFile in a MemoryDC

Posted on 1997-05-05
3
579 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

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

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: 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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

628 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