home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch16 / fileit / fileivw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-23  |  2.6 KB  |  124 lines

  1. // fileivw.cpp : implementation of the CFileitView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "fileit.h"
  6.  
  7. #include "fileidoc.h"
  8. #include "fileivw.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CFileitView
  17.  
  18. IMPLEMENT_DYNCREATE(CFileitView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CFileitView, CView)
  21.     //{{AFX_MSG_MAP(CFileitView)
  22.     ON_COMMAND(ID_FILE_TRYIT, OnFileTryit)
  23.     ON_COMMAND(ID_FILE_READIT, OnFileReadit)
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CFileitView construction/destruction
  29.  
  30. CFileitView::CFileitView()
  31. {
  32.     // TODO: add construction code here
  33. }
  34.  
  35. CFileitView::~CFileitView()
  36. {
  37. }
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CFileitView drawing
  41.  
  42. void CFileitView::OnDraw(CDC* pDC)
  43. {
  44.     CFileitDoc* pDoc = GetDocument();
  45.     ASSERT_VALID(pDoc);
  46.  
  47.     // TODO: add draw code for native data here
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CFileitView diagnostics
  52.  
  53. #ifdef _DEBUG
  54. void CFileitView::AssertValid() const
  55. {
  56.     CView::AssertValid();
  57. }
  58.  
  59. void CFileitView::Dump(CDumpContext& dc) const
  60. {
  61.     CView::Dump(dc);
  62. }
  63.  
  64. CFileitDoc* CFileitView::GetDocument() // non-debug version is inline
  65. {
  66.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFileitDoc)));
  67.     return (CFileitDoc*)m_pDocument;
  68. }
  69. #endif //_DEBUG
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CFileitView message handlers
  73.  
  74. void CFileitView::OnFileTryit()
  75. {
  76.     // TODO: Add your command handler code here
  77.  
  78.      //////////////////////
  79.      // MY CODE STARTS HERE
  80.      //////////////////////
  81.  
  82.      // Display the dlg dialog box.
  83.      dlg.DoModal();
  84.  
  85.      ////////////////////
  86.      // MY CODE ENDS HERE
  87.      ////////////////////
  88.     
  89. }
  90.  
  91. void CFileitView::OnFileReadit()
  92. {
  93.     // TODO: Add your command handler code here
  94.  
  95.      //////////////////////
  96.      // MY CODE STARTS HERE
  97.      //////////////////////
  98.  
  99.     UINT BytesRead;
  100.     char FromFile[1000];
  101.  
  102.  
  103.     // Create an object readMe of class CFile
  104.      CFile readMe("MyFile.TXT",
  105.                    CFile::modeRead );
  106.  
  107.     // Read the file into FromFile
  108.     BytesRead = readMe.Read ( FromFile,
  109.                               200 );
  110.  
  111.  
  112.     // Add a null terminator
  113.     FromFile[BytesRead] = 0;
  114.  
  115.     // Display it
  116.     MessageBox ( FromFile );
  117.  
  118.      ////////////////////
  119.      // MY CODE ENDS HERE
  120.      ////////////////////
  121.  
  122.     
  123. }
  124.