home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch22 / wave / waveview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-03  |  3.3 KB  |  156 lines

  1. // waveview.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "wave.h"
  6. #include "waveview.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CWaveView
  15.  
  16. IMPLEMENT_DYNCREATE(CWaveView, CFormView)
  17.  
  18. CWaveView::CWaveView()
  19.     : CFormView(CWaveView::IDD)
  20. {
  21.     //{{AFX_DATA_INIT(CWaveView)
  22.     m_wav = NULL;
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26. CWaveView::~CWaveView()
  27. {
  28. }
  29.  
  30. void CWaveView::DoDataExchange(CDataExchange* pDX)
  31. {
  32.     CFormView::DoDataExchange(pDX);
  33.     //{{AFX_DATA_MAP(CWaveView)
  34.     DDX_VBControl(pDX, IDC_TEGOMM_WAV, m_wav);
  35.     //}}AFX_DATA_MAP
  36. }
  37.  
  38.  
  39. BEGIN_MESSAGE_MAP(CWaveView, CFormView)
  40.     //{{AFX_MSG_MAP(CWaveView)
  41.     ON_VBXEVENT(VBN_DONE, IDC_TEGOMM_WAV, OnDoneTegommWav)
  42.     ON_BN_CLICKED(IDC_BUTTON_HIDE, OnButtonHide)
  43.     ON_BN_CLICKED(IDC_BUTTON_SHOW, OnButtonShow)
  44.     ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
  45.     //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47.  
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CWaveView message handlers
  51.  
  52. //////////////////////
  53. // MY CODE STARTS HERE
  54. //////////////////////
  55.  
  56. void CWaveView::OnInitialUpdate()
  57. {
  58.  
  59.   // Call the base class function.
  60.   CFormView::OnInitialUpdate();
  61.  
  62.   // Set the device type for playback of WAV files.
  63.    m_wav->SetStrProperty("DeviceType","WaveAudio");
  64.   
  65.   // To play through the PC speaker, simply set the DeviceType 
  66.   // to PCSpeaker as follows: 
  67.   // m_wav->SetStrProperty("DeviceType","PCSpeaker");
  68.  
  69.   // Set the WAV file name.
  70.   m_wav->SetStrProperty("FileName",
  71.                         "\\VCPROG\\WAV\\ITSBEEN1.WAV" );
  72.  
  73.   // Open the Wave device.
  74.   m_wav->SetStrProperty("Command", "Open");
  75.  
  76. }
  77.  
  78. ////////////////////
  79. // MY CODE ENDS HERE
  80. ////////////////////
  81.  
  82. void CWaveView::OnDoneTegommWav(UINT, int, CWnd*, LPVOID)
  83. {
  84. // TODO: Add your VBX event notification handler code here
  85.  
  86. //////////////////////
  87. // MY CODE STARTS HERE
  88. //////////////////////
  89.  
  90. // Get current position.
  91. long position = m_wav->GetNumProperty("Position");
  92.  
  93. // Get total length.
  94. long length = m_wav->GetNumProperty("Length");
  95.  
  96. // If current position is end position, rewind the tape.
  97. if (position == length)
  98.    m_wav->SetStrProperty("Command", "Prev");
  99.  
  100. ////////////////////
  101. // MY CODE ENDS HERE
  102. ////////////////////
  103.     
  104. }
  105.  
  106. void CWaveView::OnButtonHide()
  107. {
  108. // TODO: Add your control notification handler code here
  109.  
  110.   ///////////////////////
  111.   // MY CODE STARTS HERE
  112.   //////////////////////
  113.  
  114.   // Hide the multimedia control.
  115.   m_wav->SetNumProperty("Visible", FALSE);
  116.  
  117.   ////////////////////
  118.   // MY CODE ENDS HERE
  119.   ////////////////////
  120.     
  121. }
  122.  
  123. void CWaveView::OnButtonShow()
  124. {
  125. // TODO: Add your control notification handler code here
  126.     
  127.   //////////////////////
  128.   // MY CODE STARTS HERE
  129.   //////////////////////
  130.  
  131.   // Show the multimedia control.
  132.   m_wav->SetNumProperty("Visible", TRUE);
  133.  
  134.   ////////////////////
  135.   // MY CODE ENDS HERE
  136.   ////////////////////
  137.  
  138. }
  139.  
  140. void CWaveView::OnButtonPlay()
  141. {
  142. // TODO: Add your control notification handler code here
  143.     
  144.   ///////////////////////
  145.   // MY CODE STARTS HERE
  146.   //////////////////////
  147.  
  148.   // Play the WAV file.
  149.   m_wav->SetStrProperty("Command", "Play");
  150.  
  151.   ////////////////////
  152.   // MY CODE ENDS HERE
  153.   ////////////////////
  154.     
  155. }
  156.