WaveEditClientView.cpp
上传用户:samlee1007
上传日期:2007-01-02
资源大小:123k
文件大小:4k
- // WaveEditClientView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "MainFrm.h"
- #include "WaveEditClient.h"
- #include "WaveEditClientView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CWaveEditClientView
- IMPLEMENT_DYNCREATE(CWaveEditClientView, CFormView)
- CWaveEditClientView::CWaveEditClientView()
- : CFormView(CWaveEditClientView::IDD)
- {
- nMin = nSec = nMilli = 0;
- m_bPlaying = FALSE;
- m_bPaused = FALSE;
- m_bHidden = FALSE;
- //{{AFX_DATA_INIT(CWaveEditClientView)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- CWaveEditClientView::~CWaveEditClientView()
- {
- }
- void CWaveEditClientView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CWaveEditClientView)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CWaveEditClientView, CFormView)
- //{{AFX_MSG_MAP(CWaveEditClientView)
- ON_COMMAND(ID_PAUSE, OnPause)
- ON_UPDATE_COMMAND_UI(ID_PAUSE, OnUpdatePause)
- ON_COMMAND(ID_PLAY, OnPlay)
- ON_UPDATE_COMMAND_UI(ID_PLAY, OnUpdatePlay)
- ON_COMMAND(ID_STOP, OnStop)
- ON_UPDATE_COMMAND_UI(ID_STOP, OnUpdateStop)
- ON_COMMAND(ID_HIDE, OnHide)
- ON_COMMAND(ID_SHOW, OnShow)
- ON_WM_CREATE()
- ON_WM_TIMER()
- ON_UPDATE_COMMAND_UI(ID_HIDE, OnUpdateHide)
- ON_UPDATE_COMMAND_UI(ID_SHOW, OnUpdateShow)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CWaveEditClientView diagnostics
- #ifdef _DEBUG
- void CWaveEditClientView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CWaveEditClientView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CWaveEditClientView message handlers
- void CWaveEditClientView::OnPause()
- {
- //m_waveEditObject.SetCursor();
- m_bPaused = !m_bPaused;
- if (m_bPaused){
- m_waveEditObject.SetPause();
- KillTimer(1);
- }
- else {
- SetTimer(1, 50, NULL);
- m_waveEditObject.SetPlay();
- }
-
- }
- void CWaveEditClientView::OnUpdatePause(CCmdUI* pCmdUI)
- {
- if (!m_bPlaying)
- pCmdUI->Enable(FALSE);
- else
- pCmdUI->SetCheck( m_bPaused);
-
- }
- void CWaveEditClientView::OnPlay()
- {
- m_bHidden = FALSE;
- if(m_waveEditObject.m_bAutoRelease){
- m_waveEditObject.ShowApp();
- m_waveEditObject.ShowWindow();
- }
-
- SetTimer(1,50, NULL);
- m_bPlaying = TRUE;
- nMilli = nSec = nMin = 0;
- m_waveEditObject.SetPlay();
-
- }
- void CWaveEditClientView::OnUpdatePlay(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!m_bPlaying);
-
- }
- void CWaveEditClientView::OnStop()
- {
- m_bPlaying = FALSE;
- m_waveEditObject.SetStop();
- KillTimer(1);
-
- }
- void CWaveEditClientView::OnUpdateStop(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_bPlaying);
-
- }
- void CWaveEditClientView::OnHide()
- {
-
- m_waveEditObject.HideApp();
- m_bHidden = TRUE;
- }
- void CWaveEditClientView::OnUpdateHide(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!m_bHidden);
-
- }
- void CWaveEditClientView::OnShow()
- {
-
- m_waveEditObject.ShowApp();
- m_bHidden = FALSE;
-
- }
- void CWaveEditClientView::OnUpdateShow(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_bHidden);
-
- }
- void CWaveEditClientView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
-
- if(!m_waveEditObject.CreateDispatch(_T("WaveEdit.Document")))
- {
- AfxMessageBox("Cannot start WaveEdit");
- }
-
- m_waveEditObject.ShowApp();
- m_waveEditObject.ShowWindow();
- m_waveEditObject.SetCursor();
- }
- int CWaveEditClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFormView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- return 0;
- }
- void CWaveEditClientView::OnTimer(UINT nIDEvent)
- {
-
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- CStatusBar* pStatus = &pFrame->m_wndStatusBar;
- m_waveEditObject.IsWaveEnd();
- if (m_waveEditObject.result){
- KillTimer(1);
- m_bPlaying = FALSE;
- }
- char szTime[10];
- nMilli++;
-
- if (nMilli > 24){
- nMilli = 0; nSec++;
- }
- if (nSec > 60){
- nSec = 0; nMin++;
- }
- wsprintf(szTime, "%02i:%02i:%02i", nMin, nSec, nMilli);
- pStatus->SetPaneText(
- pStatus->CommandToIndex(ID_INDICATOR_TIME), LPCSTR(szTime));
-
- CFormView::OnTimer(nIDEvent);
- }