home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch09 / speed / speedvw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-17  |  2.7 KB  |  123 lines

  1. // speedvw.cpp : implementation of the CSpeedView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "speed.h"
  6.  
  7. #include "speeddoc.h"
  8. #include "speedvw.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CSpeedView
  17.  
  18. IMPLEMENT_DYNCREATE(CSpeedView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CSpeedView, CView)
  21.     //{{AFX_MSG_MAP(CSpeedView)
  22.     ON_COMMAND(ID_FILE_TRYIT, OnFileTryit)
  23.     ON_COMMAND(ID_FILE_CURRENTSPEED, OnFileCurrentspeed)
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CSpeedView construction/destruction
  29.  
  30. CSpeedView::CSpeedView()
  31. {
  32.     // TODO: add construction code here
  33. }
  34.  
  35. CSpeedView::~CSpeedView()
  36. {
  37. }
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CSpeedView drawing
  41.  
  42. void CSpeedView::OnDraw(CDC* pDC)
  43. {
  44.     CSpeedDoc* pDoc = GetDocument();
  45.     ASSERT_VALID(pDoc);
  46.  
  47.     // TODO: add draw code for native data here
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CSpeedView diagnostics
  52.  
  53. #ifdef _DEBUG
  54. void CSpeedView::AssertValid() const
  55. {
  56.     CView::AssertValid();
  57. }
  58.  
  59. void CSpeedView::Dump(CDumpContext& dc) const
  60. {
  61.     CView::Dump(dc);
  62. }
  63.  
  64. CSpeedDoc* CSpeedView::GetDocument() // non-debug version is inline
  65. {
  66.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSpeedDoc)));
  67.     return (CSpeedDoc*)m_pDocument;
  68. }
  69. #endif //_DEBUG
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CSpeedView message handlers
  73.  
  74. void CSpeedView::OnFileTryit()
  75. {
  76.     // TODO: Add your command handler code here
  77.  
  78.  
  79.      //////////////////////
  80.      // MY CODE STARTS HERE
  81.      //////////////////////
  82.  
  83.     // Display the dialog box.
  84.     // Note that DoModal() is a member function of the CWnd class.
  85.     // dlg is an object of the CMyDlg class, and CMyDlg class 
  86.     // is derived from the CDialog class which is derived from
  87.     // the CWnd class. Thus, you can execute DoModal() on the
  88.     // dlg object.
  89.     dlg.DoModal();
  90.  
  91.      ////////////////////
  92.      // MY CODE ENDS HERE
  93.      ////////////////////
  94.     
  95. }
  96.  
  97. void CSpeedView::OnFileCurrentspeed()
  98. {
  99.     // TODO: Add your command handler code here
  100.  
  101.      //////////////////////
  102.      // MY CODE STARTS HERE
  103.      //////////////////////
  104.  
  105.      // Local variables
  106.      CString Message;
  107.      char Current[25];
  108.      
  109.      // Prepare the message
  110.      itoa ( dlg.m_ScrollPosition, Current, 10 );
  111.      Message = (CString) "Current Speed is: " +  Current;
  112.      
  113.      // Display the message
  114.      MessageBox ( Message, "Current Speed", MB_OK);
  115.  
  116.  
  117.      ////////////////////
  118.      // MY CODE ENDS HERE
  119.      ////////////////////
  120.  
  121.     
  122. }
  123.