WaveEditClientView.cpp
上传用户:samlee1007
上传日期:2007-01-02
资源大小:123k
文件大小:4k
源码类别:

文件操作

开发平台:

Visual C++

  1. // WaveEditClientView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MainFrm.h"
  5. #include "WaveEditClient.h"
  6. #include "WaveEditClientView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CWaveEditClientView
  14. IMPLEMENT_DYNCREATE(CWaveEditClientView, CFormView)
  15. CWaveEditClientView::CWaveEditClientView()
  16. : CFormView(CWaveEditClientView::IDD)
  17. {
  18. nMin = nSec = nMilli = 0;
  19. m_bPlaying = FALSE;
  20. m_bPaused = FALSE;
  21. m_bHidden = FALSE;
  22. //{{AFX_DATA_INIT(CWaveEditClientView)
  23. // NOTE: the ClassWizard will add member initialization here
  24. //}}AFX_DATA_INIT
  25. }
  26. CWaveEditClientView::~CWaveEditClientView()
  27. {
  28. }
  29. void CWaveEditClientView::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CFormView::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CWaveEditClientView)
  33. // NOTE: the ClassWizard will add DDX and DDV calls here
  34. //}}AFX_DATA_MAP
  35. }
  36. BEGIN_MESSAGE_MAP(CWaveEditClientView, CFormView)
  37. //{{AFX_MSG_MAP(CWaveEditClientView)
  38. ON_COMMAND(ID_PAUSE, OnPause)
  39. ON_UPDATE_COMMAND_UI(ID_PAUSE, OnUpdatePause)
  40. ON_COMMAND(ID_PLAY, OnPlay)
  41. ON_UPDATE_COMMAND_UI(ID_PLAY, OnUpdatePlay)
  42. ON_COMMAND(ID_STOP, OnStop)
  43. ON_UPDATE_COMMAND_UI(ID_STOP, OnUpdateStop)
  44. ON_COMMAND(ID_HIDE, OnHide)
  45. ON_COMMAND(ID_SHOW, OnShow)
  46. ON_WM_CREATE()
  47. ON_WM_TIMER()
  48. ON_UPDATE_COMMAND_UI(ID_HIDE, OnUpdateHide)
  49. ON_UPDATE_COMMAND_UI(ID_SHOW, OnUpdateShow)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CWaveEditClientView diagnostics
  54. #ifdef _DEBUG
  55. void CWaveEditClientView::AssertValid() const
  56. {
  57. CFormView::AssertValid();
  58. }
  59. void CWaveEditClientView::Dump(CDumpContext& dc) const
  60. {
  61. CFormView::Dump(dc);
  62. }
  63. #endif //_DEBUG
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CWaveEditClientView message handlers
  66. void CWaveEditClientView::OnPause() 
  67. {
  68. //m_waveEditObject.SetCursor();
  69. m_bPaused = !m_bPaused;
  70. if (m_bPaused){
  71. m_waveEditObject.SetPause();
  72. KillTimer(1);
  73. }
  74. else {
  75. SetTimer(1, 50, NULL);
  76. m_waveEditObject.SetPlay();
  77. }
  78. }
  79. void CWaveEditClientView::OnUpdatePause(CCmdUI* pCmdUI) 
  80. {
  81. if (!m_bPlaying)
  82. pCmdUI->Enable(FALSE);
  83. else
  84. pCmdUI->SetCheck( m_bPaused);
  85. }
  86. void CWaveEditClientView::OnPlay() 
  87. {
  88. m_bHidden = FALSE;
  89. if(m_waveEditObject.m_bAutoRelease){
  90. m_waveEditObject.ShowApp();
  91. m_waveEditObject.ShowWindow();
  92. }
  93. SetTimer(1,50, NULL);
  94. m_bPlaying = TRUE;
  95. nMilli = nSec = nMin = 0;
  96. m_waveEditObject.SetPlay();
  97. }
  98. void CWaveEditClientView::OnUpdatePlay(CCmdUI* pCmdUI) 
  99. {
  100. pCmdUI->Enable(!m_bPlaying);
  101. }
  102. void CWaveEditClientView::OnStop() 
  103. {
  104. m_bPlaying = FALSE;
  105. m_waveEditObject.SetStop();
  106. KillTimer(1);
  107. }
  108. void CWaveEditClientView::OnUpdateStop(CCmdUI* pCmdUI) 
  109. {
  110. pCmdUI->Enable(m_bPlaying);
  111. }
  112. void CWaveEditClientView::OnHide() 
  113. {
  114. m_waveEditObject.HideApp();
  115. m_bHidden = TRUE;
  116. }
  117. void CWaveEditClientView::OnUpdateHide(CCmdUI* pCmdUI) 
  118. {
  119. pCmdUI->Enable(!m_bHidden);
  120. }
  121. void CWaveEditClientView::OnShow() 
  122. {
  123. m_waveEditObject.ShowApp();
  124. m_bHidden = FALSE;
  125. }
  126. void CWaveEditClientView::OnUpdateShow(CCmdUI* pCmdUI) 
  127. {
  128. pCmdUI->Enable(m_bHidden);
  129. }
  130. void CWaveEditClientView::OnInitialUpdate() 
  131. {
  132. CFormView::OnInitialUpdate();
  133. if(!m_waveEditObject.CreateDispatch(_T("WaveEdit.Document")))
  134. {
  135. AfxMessageBox("Cannot start WaveEdit");
  136. }
  137. m_waveEditObject.ShowApp();
  138. m_waveEditObject.ShowWindow();
  139. m_waveEditObject.SetCursor();
  140. }
  141. int CWaveEditClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  142. {
  143. if (CFormView::OnCreate(lpCreateStruct) == -1)
  144. return -1;
  145. return 0;
  146. }
  147. void CWaveEditClientView::OnTimer(UINT nIDEvent) 
  148. {
  149. CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
  150. CStatusBar* pStatus = &pFrame->m_wndStatusBar;
  151. m_waveEditObject.IsWaveEnd();
  152. if (m_waveEditObject.result){
  153. KillTimer(1);
  154. m_bPlaying = FALSE;
  155. }
  156. char szTime[10];
  157. nMilli++;
  158. if (nMilli > 24){
  159. nMilli = 0; nSec++;
  160. }
  161. if (nSec > 60){
  162. nSec = 0; nMin++;
  163. }
  164. wsprintf(szTime, "%02i:%02i:%02i", nMin, nSec, nMilli);
  165. pStatus->SetPaneText(
  166. pStatus->CommandToIndex(ID_INDICATOR_TIME), LPCSTR(szTime));
  167. CFormView::OnTimer(nIDEvent);
  168. }