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

  1. // SpltView.cpp : implementation of the CSplitterView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "splitter.h"
  6.  
  7. #include "SplitDoc.h"
  8. #include "spltView.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. // CSplitterView
  18.  
  19. IMPLEMENT_DYNCREATE(CSplitterView, CScrollView)
  20.  
  21. BEGIN_MESSAGE_MAP(CSplitterView, CScrollView)
  22.     //{{AFX_MSG_MAP(CSplitterView)
  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. // CSplitterView construction/destruction
  30.  
  31. CSplitterView::CSplitterView()
  32. {
  33. }
  34.  
  35. CSplitterView::~CSplitterView()
  36. {
  37. }
  38.  
  39. BOOL CSplitterView::PreCreateWindow(CREATESTRUCT& cs)
  40. {
  41.     return CScrollView::PreCreateWindow(cs);
  42. }
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CSplitterView drawing
  46.  
  47. void CSplitterView::OnDraw(CDC* pDC)
  48. {
  49.     CSplitterDoc* 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. // CSplitterView diagnostics
  63.  
  64. #ifdef _DEBUG
  65. void CSplitterView::AssertValid() const
  66. {
  67.     CScrollView::AssertValid();
  68. }
  69.  
  70. void CSplitterView::Dump(CDumpContext& dc) const
  71. {
  72.     CScrollView::Dump(dc);
  73. }
  74.  
  75. CSplitterDoc* CSplitterView::GetDocument() // non-debug version is inline
  76. {
  77.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSplitterDoc)));
  78.     return (CSplitterDoc*)m_pDocument;
  79. }
  80. #endif //_DEBUG
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CSplitterView message handlers
  84.  
  85. void CSplitterView::OnInitialUpdate() 
  86. {
  87.     CScrollView::OnInitialUpdate();
  88.  
  89.     SetScrollSizes(MM_TEXT, CSize(640, 480));
  90. }
  91.