home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c05 / owndraw / odraview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.1 KB  |  84 lines

  1. // ODraView.cpp : implementation of the COwnerDrawMenusView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "OwnDraw.h"
  6.  
  7. #include "ODrawDoc.h"
  8. #include "ODraView.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. // COwnerDrawMenusView
  18.  
  19. IMPLEMENT_DYNCREATE(COwnerDrawMenusView, CView)
  20.  
  21. BEGIN_MESSAGE_MAP(COwnerDrawMenusView, CView)
  22.     //{{AFX_MSG_MAP(COwnerDrawMenusView)
  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. END_MESSAGE_MAP()
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // COwnerDrawMenusView construction/destruction
  30.  
  31. COwnerDrawMenusView::COwnerDrawMenusView()
  32. {
  33. }
  34.  
  35. COwnerDrawMenusView::~COwnerDrawMenusView()
  36. {
  37. }
  38.  
  39. BOOL COwnerDrawMenusView::PreCreateWindow(CREATESTRUCT& cs)
  40. {
  41.     return CView::PreCreateWindow(cs);
  42. }
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // COwnerDrawMenusView drawing
  46.  
  47. void COwnerDrawMenusView::OnDraw(CDC* pDC)
  48. {
  49.     COwnerDrawMenusDoc* pDoc = GetDocument();
  50.     ASSERT_VALID(pDoc);
  51.  
  52.     CRect r;
  53.     GetClientRect(&r);
  54.     int x = r.right / 2, y = r.bottom / 2;
  55.  
  56.     pDC->SetTextColor(pDoc->GetColor());
  57.     pDC->SetTextAlign (TA_CENTER | TA_BASELINE);
  58.     pDC->TextOut (x, y, pDoc->GetPhrase());
  59. }
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // COwnerDrawMenusView diagnostics
  63.  
  64. #ifdef _DEBUG
  65. void COwnerDrawMenusView::AssertValid() const
  66. {
  67.     CView::AssertValid();
  68. }
  69.  
  70. void COwnerDrawMenusView::Dump(CDumpContext& dc) const
  71. {
  72.     CView::Dump(dc);
  73. }
  74.  
  75. COwnerDrawMenusDoc* COwnerDrawMenusView::GetDocument() // non-debug version is inline
  76. {
  77.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COwnerDrawMenusDoc)));
  78.     return (COwnerDrawMenusDoc*)m_pDocument;
  79. }
  80. #endif //_DEBUG
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // COwnerDrawMenusView message handlers
  84.