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

  1. // seekivw.cpp : implementation of the CSeekitView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "seekit.h"
  6.  
  7. #include "seekidoc.h"
  8. #include "seekivw.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CSeekitView
  17.  
  18. IMPLEMENT_DYNCREATE(CSeekitView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CSeekitView, CView)
  21.     //{{AFX_MSG_MAP(CSeekitView)
  22.     ON_COMMAND(ID_FILE_SAMPLINGRATE, OnFileSamplingrate)
  23.     //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CSeekitView construction/destruction
  28.  
  29. CSeekitView::CSeekitView()
  30. {
  31.     // TODO: add construction code here
  32. }
  33.  
  34. CSeekitView::~CSeekitView()
  35. {
  36. }
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CSeekitView drawing
  40.  
  41. void CSeekitView::OnDraw(CDC* pDC)
  42. {
  43.     CSeekitDoc* pDoc = GetDocument();
  44.     ASSERT_VALID(pDoc);
  45.  
  46.     // TODO: add draw code for native data here
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CSeekitView diagnostics
  51.  
  52. #ifdef _DEBUG
  53. void CSeekitView::AssertValid() const
  54. {
  55.     CView::AssertValid();
  56. }
  57.  
  58. void CSeekitView::Dump(CDumpContext& dc) const
  59. {
  60.     CView::Dump(dc);
  61. }
  62.  
  63. CSeekitDoc* CSeekitView::GetDocument() // non-debug version is inline
  64. {
  65.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSeekitDoc)));
  66.     return (CSeekitDoc*)m_pDocument;
  67. }
  68. #endif //_DEBUG
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CSeekitView message handlers
  72.  
  73. void CSeekitView::OnFileSamplingrate()
  74. {
  75.     // TODO: Add your command handler code here
  76.  
  77.     //////////////////////
  78.     // MY CODE STARTS HERE
  79.     //////////////////////
  80.  
  81.     char BytesRead[2];
  82.  
  83.     unsigned int *ptrMyInteger;
  84.     unsigned int  MyInteger;
  85.     char sSamplingRate[10];
  86.     CString Message;
  87.  
  88.      // Create an object (for reading the .WAV file)
  89.      CFile theWAVfile ("C:\\Windows\\DING.WAV",
  90.                         CFile::modeRead ) ;
  91.  
  92.     // Seek to byte number 24 (base 0)
  93.     theWAVfile.Seek ( 24, CFile::begin );
  94.  
  95.     // Read 2 bytes from the .WAV file
  96.     theWAVfile.Read ( BytesRead, 2 );
  97.  
  98.  
  99.     ptrMyInteger = (unsigned int *)&BytesRead[0];
  100.  
  101.     MyInteger = *ptrMyInteger;
  102.  
  103.     // Display the sampling rate
  104.     itoa ( MyInteger, sSamplingRate, 10 );
  105.     Message =
  106.     (CString)"The sampling rate of DING.WAV is: " +
  107.                              sSamplingRate ;
  108.  
  109.     MessageBox (Message);
  110.  
  111.  
  112.   ////////////////////
  113.   // MY CODE ENDS HERE
  114.   ////////////////////
  115.  
  116.  
  117.     
  118. }
  119.