www.pudn.com > VCBOOKSOURCES.zip > BITDEMOVIEW.CPP, change:1998-02-18,size:3102b


// BitDemoView.cpp : implementation of the CBitDemoView class 
// 
 
#include "stdafx.h" 
#include "BitDemo.h" 
 
#include "BitDemoDoc.h" 
#include "BitDemoView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CBitDemoView 
 
IMPLEMENT_DYNCREATE(CBitDemoView, CView) 
 
BEGIN_MESSAGE_MAP(CBitDemoView, CView) 
   //{{AFX_MSG_MAP(CBitDemoView) 
      // NOTE - the ClassWizard will add and remove mapping macros here. 
      //    DO NOT EDIT what you see in these blocks of generated code! 
   //}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CBitDemoView construction/destruction 
 
CBitDemoView::CBitDemoView() 
{ 
   // TODO: add construction code here 
   BITMAP BM; 
 
   m_Bitmap.LoadBitmap (IDB_BITMAP1); 
   m_Bitmap.GetObject (sizeof (BM), &BM); 
   m_BitmapWidth = BM.bmWidth; 
   m_BitmapHeight = BM.bmHeight; 
} 
 
CBitDemoView::~CBitDemoView() 
{ 
} 
 
BOOL CBitDemoView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
   // TODO: Modify the Window class or styles here by modifying 
   //  the CREATESTRUCT cs 
 
   return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CBitDemoView drawing 
 
void CBitDemoView::OnDraw(CDC* pDC) 
{ 
   CBitDemoDoc* pDoc = GetDocument(); 
   ASSERT_VALID(pDoc); 
 
   // TODO: add draw code for native data here 
   CDC MemDC; 
   RECT ClientRect; 
 
   // create memory device context object and select bitmap  
   // object into it: 
   MemDC.CreateCompatibleDC (NULL); 
   MemDC.SelectObject (&m_Bitmap); 
 
   // get current dimensions of view window:                    
   GetClientRect (&ClientRect); 
 
   // display bitmap, stretching it to fit view window:                       
   pDC->StretchBlt 
      (0,                // coordinates of upper-left corner of  
      0,                 // destination rectangle; 
      ClientRect.right,  // width of destination rectangle; 
      ClientRect.bottom, // height of destination rectangle; 
      &MemDC,            // source device context object; 
      0,                 // coordinates of upper-left corner of  
      0,                 // source rectangle; 
      m_BitmapWidth,     // width of source rectangle; 
      m_BitmapHeight,    // height of source rectangle; 
      SRCCOPY);          // raster-operation code 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CBitDemoView diagnostics 
 
#ifdef _DEBUG 
void CBitDemoView::AssertValid() const 
{ 
   CView::AssertValid(); 
} 
 
void CBitDemoView::Dump(CDumpContext& dc) const 
{ 
   CView::Dump(dc); 
} 
 
CBitDemoDoc* CBitDemoView::GetDocument() // non-debug version is inline 
{ 
   ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBitDemoDoc))); 
   return (CBitDemoDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CBitDemoView message handlers