home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / VIEWEX / SIMPVW.CP_ / SIMPVW.CP
Encoding:
Text File  |  1993-02-08  |  3.2 KB  |  129 lines

  1. // simpvw.cpp : implementation of the simple view classes
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14.  
  15. #include "stdafx.h"
  16. #include "viewex.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CTextView
  25.  
  26. IMPLEMENT_DYNCREATE(CTextView, CView)
  27.  
  28. BEGIN_MESSAGE_MAP(CTextView, CView)
  29.     //{{AFX_MSG_MAP(CTextView)
  30.     ON_WM_MOUSEACTIVATE()
  31.     //}}AFX_MSG_MAP
  32.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  33.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CTextView construction/destruction
  38.  
  39. CTextView::CTextView()
  40. {
  41. }
  42.  
  43. CTextView::~CTextView()
  44. {
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CTextView drawing
  49.  
  50. void CTextView::OnDraw(CDC* pDC)
  51. {
  52.     CMainDoc* pDoc = GetDocument();
  53.  
  54.     CRect rect;
  55.     GetClientRect(rect);
  56.     pDC->SetTextAlign(TA_BASELINE | TA_CENTER);
  57.     pDC->SetTextColor(pDoc->m_colorData);
  58.     pDC->SetBkMode(TRANSPARENT);
  59.     // center in the window
  60.     pDC->TextOut(rect.Width() / 2, rect.Height() / 2,
  61.         pDoc->m_strData, pDoc->m_strData.GetLength());
  62. }
  63.  
  64. BOOL CTextView::OnPreparePrinting(CPrintInfo* pInfo)
  65. {
  66.     // default preparation
  67.     return DoPreparePrinting(pInfo);
  68. }
  69.  
  70. int CTextView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
  71. {
  72.     // side-step CView's implementation since we don't want to activate
  73.     //  this view
  74.     return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
  75. }
  76.  
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CColorView - does not print
  79.  
  80. IMPLEMENT_DYNCREATE(CColorView, CView)
  81.  
  82. BEGIN_MESSAGE_MAP(CColorView, CView)
  83.     //{{AFX_MSG_MAP(CColorView)
  84.     ON_WM_MOUSEACTIVATE()
  85.     //}}AFX_MSG_MAP
  86. END_MESSAGE_MAP()
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CColorView construction/destruction
  90.  
  91. CColorView::CColorView()
  92. {
  93. }
  94.  
  95. CColorView::~CColorView()
  96. {
  97. }
  98.  
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CColorView drawing
  101.  
  102. void CColorView::OnDraw(CDC* pDC)
  103. {
  104.     CMainDoc* pDoc = GetDocument();
  105.  
  106.     CRect rect;
  107.     GetClientRect(rect);
  108.  
  109.     // fill the view with the specified color
  110.     CBrush br(pDoc->m_colorData);
  111.     pDC->FillRect(rect, &br);
  112. }
  113.  
  114.  
  115. int CColorView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
  116. {
  117.     // side-step CView's implementation since we don't want to activate
  118.     //  this view
  119.     return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
  120. }
  121.  
  122. void CColorView::OnActivateView(BOOL, CView*, CView*)
  123. {
  124.     ASSERT(FALSE);      // output only view - should never be active
  125. }
  126.  
  127.  
  128. /////////////////////////////////////////////////////////////////////////////
  129.