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

  1. // DefaultView.cpp : implementation of the CNormalView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "SDI2Views.h"
  6.  
  7. #include "SDI2ViewsDoc.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.     //}}AFX_MSG_MAP
  24.     // Standard printing commands
  25.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  26.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  27.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  28. END_MESSAGE_MAP()
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CDefaultView construction/destruction
  32.  
  33. CDefaultView::CDefaultView()
  34. {
  35. }
  36.  
  37. CDefaultView::~CDefaultView()
  38. {
  39. }
  40.  
  41. BOOL CDefaultView::PreCreateWindow(CREATESTRUCT& cs)
  42. {
  43.     return CView::PreCreateWindow(cs);
  44. }
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CDefaultView drawing
  48.  
  49. void CDefaultView::OnDraw(CDC* pDC)
  50. {
  51.     CSDI2ViewsDoc* pDoc = GetDocument();
  52.     ASSERT_VALID(pDoc);
  53.  
  54.     CRect rect;
  55.     GetClientRect(&rect);
  56.     int x = rect.Width() / 2;
  57.     int y = rect.Height() / 2;
  58.  
  59.     pDC->SetTextAlign(TA_BASELINE | TA_CENTER);
  60.     pDC->SetTextColor(pDoc->GetColor());
  61.  
  62.     pDC->TextOut(x, y, pDoc->GetPhrase());
  63. }
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CDefaultView diagnostics
  67.  
  68. #ifdef _DEBUG
  69. void CDefaultView::AssertValid() const
  70. {
  71.     CView::AssertValid();
  72. }
  73.  
  74. void CDefaultView::Dump(CDumpContext& dc) const
  75. {
  76.     CView::Dump(dc);
  77. }
  78.  
  79. CSDI2ViewsDoc* CDefaultView::GetDocument() // non-debug version is inline
  80. {
  81.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSDI2ViewsDoc)));
  82.     return (CSDI2ViewsDoc*)m_pDocument;
  83. }
  84. #endif //_DEBUG
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CDefaultView message handlers
  88.  
  89.