home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / mdi2viewsb / defaultview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.3 KB  |  95 lines

  1. // DefaultView.cpp : implementation of the CDefaultView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MDI2ViewsB.h"
  6.  
  7. #include "MDI2ViewsBDoc.h"
  8. #include "DefaultView.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CDefaultView
  18.  
  19. IMPLEMENT_DYNCREATE(CDefaultView, CView)
  20.  
  21. BEGIN_MESSAGE_MAP(CDefaultView, CView)
  22.     //{{AFX_MSG_MAP(CDefaultView)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26.     // Standard printing commands
  27.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  28.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  29.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDefaultView construction/destruction
  34.  
  35. CDefaultView::CDefaultView()
  36. {
  37.     // TODO: add construction code here
  38.  
  39. }
  40.  
  41. CDefaultView::~CDefaultView()
  42. {
  43. }
  44.  
  45. BOOL CDefaultView::PreCreateWindow(CREATESTRUCT& cs)
  46. {
  47.     // TODO: Modify the Window class or styles here by modifying
  48.     //  the CREATESTRUCT cs
  49.  
  50.     return CView::PreCreateWindow(cs);
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CDefaultView drawing
  55.  
  56. void CDefaultView::OnDraw(CDC* pDC)
  57. {
  58.     CMDI2ViewsBDoc* pDoc = GetDocument();
  59.     ASSERT_VALID(pDoc);
  60.  
  61.     CRect rect;
  62.     GetClientRect(&rect);
  63.     int x = rect.Width() / 2;
  64.     int y = rect.Height() / 2;
  65.  
  66.     pDC->SetTextAlign(TA_BASELINE | TA_CENTER);
  67.     pDC->SetTextColor(pDoc->GetColor());
  68.  
  69.     pDC->TextOut(x, y, pDoc->GetPhrase());
  70. }
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CDefaultView diagnostics
  74.  
  75. #ifdef _DEBUG
  76. void CDefaultView::AssertValid() const
  77. {
  78.     CView::AssertValid();
  79. }
  80.  
  81. void CDefaultView::Dump(CDumpContext& dc) const
  82. {
  83.     CView::Dump(dc);
  84. }
  85.  
  86. CMDI2ViewsBDoc* CDefaultView::GetDocument() // non-debug version is inline
  87. {
  88.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMDI2ViewsBDoc)));
  89.     return (CMDI2ViewsBDoc*)m_pDocument;
  90. }
  91. #endif //_DEBUG
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CDefaultView message handlers
  95.