home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch34 / mytext / mytexvw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-10  |  3.1 KB  |  128 lines

  1. // mytexvw.cpp : implementation of the CMytextView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mytext.h"
  6.  
  7. #include "mytexdoc.h"
  8. #include "mytexvw.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMytextView
  17.  
  18. IMPLEMENT_DYNCREATE(CMytextView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CMytextView, CView)
  21.     //{{AFX_MSG_MAP(CMytextView)
  22.         // NOTE - the ClassWizard will add and remove mapping macros here.
  23.         //    DO NOT EDIT what you see in these blocks of generated code!
  24.     //}}AFX_MSG_MAP
  25.     // Standard printing commands
  26.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  27.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  28. END_MESSAGE_MAP()
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CMytextView construction/destruction
  32.  
  33. CMytextView::CMytextView()
  34. {
  35.     // TODO: add construction code here
  36. }
  37.  
  38. CMytextView::~CMytextView()
  39. {
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CMytextView drawing
  44.  
  45. void CMytextView::OnDraw(CDC* pDC)
  46. {
  47.     CMytextDoc* pDoc = GetDocument();
  48.     ASSERT_VALID(pDoc);
  49.  
  50.     // TODO: add draw code for native data here
  51.  
  52.      //////////////////////
  53.      // MY CODE STARTS HERE
  54.      //////////////////////
  55.  
  56.      CFont MyFont;
  57.  
  58.      MyFont.CreateFont   ( 25,
  59.                            0,
  60.                            0,
  61.                            0,
  62.                            400,
  63.                            FALSE,
  64.                            FALSE,
  65.                            0,
  66.                            ANSI_CHARSET,
  67.                            OUT_DEFAULT_PRECIS,
  68.                            CLIP_DEFAULT_PRECIS,
  69.                            DEFAULT_QUALITY,
  70.                            DEFAULT_PITCH|FF_SWISS,
  71.                            "Arial");
  72.  
  73.  
  74.      CFont* pOldFont = (CFont*)pDC->SelectObject(&MyFont);
  75.  
  76.      pDC->TextOut(10,
  77.                   20,
  78.                   "Testing the Arial font");
  79.  
  80.      ////////////////////
  81.      // MY CODE ENDS HERE
  82.      ////////////////////
  83.  
  84. }
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CMytextView printing
  88.  
  89. BOOL CMytextView::OnPreparePrinting(CPrintInfo* pInfo)
  90. {
  91.     // default preparation
  92.     return DoPreparePrinting(pInfo);
  93. }
  94.  
  95. void CMytextView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  96. {
  97.     // TODO: add extra initialization before printing
  98. }
  99.  
  100. void CMytextView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  101. {
  102.     // TODO: add cleanup after printing
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CMytextView diagnostics
  107.  
  108. #ifdef _DEBUG
  109. void CMytextView::AssertValid() const
  110. {
  111.     CView::AssertValid();
  112. }
  113.  
  114. void CMytextView::Dump(CDumpContext& dc) const
  115. {
  116.     CView::Dump(dc);
  117. }
  118.  
  119. CMytextDoc* CMytextView::GetDocument() // non-debug version is inline
  120. {
  121.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMytextDoc)));
  122.     return (CMytextDoc*)m_pDocument;
  123. }
  124. #endif //_DEBUG
  125.  
  126. /////////////////////////////////////////////////////////////////////////////
  127. // CMytextView message handlers
  128.