Solved

PlayMetaFile in a MemoryDC

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now