GME
13
|
00001 // PreviewWnd.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "gme.h" 00006 #include "PreviewWnd.h" 00007 00008 #ifdef _DEBUG 00009 #define new DEBUG_NEW 00010 #undef THIS_FILE 00011 static char THIS_FILE[] = __FILE__; 00012 #endif 00013 00015 // CPreviewBtn 00016 00017 CPreviewBtn::CPreviewBtn() 00018 { 00019 m_bitmapDC = NULL; 00020 } 00021 00022 CPreviewBtn::~CPreviewBtn() 00023 { 00024 if (m_bitmapDC) 00025 { 00026 CBitmap *bmp = m_bitmapDC->GetCurrentBitmap(); 00027 delete m_bitmapDC; 00028 if (bmp) 00029 delete bmp; 00030 } 00031 } 00032 00033 00034 BEGIN_MESSAGE_MAP(CPreviewBtn, CButton) 00035 //{{AFX_MSG_MAP(CPreviewBtn) 00036 //}}AFX_MSG_MAP 00037 END_MESSAGE_MAP() 00038 00039 00041 // CPreviewBtn message handlers 00042 void CPreviewBtn::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct) 00043 { 00044 if (lpDrawItemStruct->itemAction == ODA_DRAWENTIRE) 00045 { 00046 CDC dc; 00047 dc.Attach(lpDrawItemStruct->hDC); // device context for painting 00048 RECT rect; 00049 GetClientRect(&rect); 00050 CRect crect(rect); 00051 CRect vrect = crect; 00052 00053 dc.SetMapMode(MM_TEXT); 00054 dc.DPtoLP(&vrect); 00055 if (!m_bitmapDC) 00056 return; 00057 00058 m_bitmapDC->SetMapMode(MM_TEXT); 00059 // TODO: Error checking 00060 dc.BitBlt(0, 0, vrect.Width(), vrect.Height(), m_bitmapDC, 0, 0, SRCCOPY); 00061 dc.Detach(); 00062 } 00063 } 00064 00065