📄 waveeditorview.cpp
字号:
// WaveEditorView.cpp : implementation file
//
#include "stdafx.h"
#include "WaveEdit.h"
#include "WaveEditorView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWaveEditorView
IMPLEMENT_DYNCREATE(CWaveEditorView, CFormView)
CWaveEditorView::CWaveEditorView()
: CFormView(CWaveEditorView::IDD)
{
m_bPlaying = FALSE;
m_bPaused = FALSE;
m_bStopped = TRUE;
//{{AFX_DATA_INIT(CWaveEditorView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CWaveEditorView::~CWaveEditorView()
{
}
void CWaveEditorView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWaveEditorView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWaveEditorView, CFormView)
//{{AFX_MSG_MAP(CWaveEditorView)
ON_COMMAND(ID_PLAY, OnPlay)
ON_COMMAND(ID_STOP, OnStop)
ON_COMMAND(ID_PAUSE, OnPause)
ON_UPDATE_COMMAND_UI(ID_PAUSE, OnUpdatePause)
ON_UPDATE_COMMAND_UI(ID_PLAY, OnUpdatePlay)
ON_UPDATE_COMMAND_UI(ID_STOP, OnUpdateStop)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_TIMER()
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWaveEditorView diagnostics
#ifdef _DEBUG
void CWaveEditorView::AssertValid() const
{
CFormView::AssertValid();
}
void CWaveEditorView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWaveEditorView message handlers
int CWaveEditorView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
void CWaveEditorView::OnPlay()
{
SetTimer(1, 25, NULL);
m_bPlaying = TRUE;
m_bStopped = FALSE;
}
void CWaveEditorView::OnUpdatePlay(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!m_bPlaying);
}
void CWaveEditorView::OnStop()
{
KillTimer(1);
m_WaveEditCtrl.m_ptCaretPos.x = 0;
m_WaveEditCtrl.MoveCaret();
m_bStopped = TRUE;
m_bPlaying = FALSE;
m_bPaused = FALSE;
}
void CWaveEditorView::OnUpdateStop(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!m_bStopped);
}
void CWaveEditorView::OnPause()
{
m_bPaused = !m_bPaused;
if (m_bPaused)
KillTimer(1);
else
SetTimer(1, 25, NULL);
}
void CWaveEditorView::OnUpdatePause(CCmdUI* pCmdUI)
{
if (!m_bPlaying)
pCmdUI->Enable(FALSE);
else
pCmdUI->SetCheck( m_bPaused);
}
void CWaveEditorView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CRect rect;
GetDlgItem(IDC_WAVE_EDIT)->GetWindowRect(rect);
ScreenToClient(rect);
m_WaveEditCtrl.Create(WS_VISIBLE | WS_CHILD, rect, this, 1000);
}
void CWaveEditorView::OnSetFocus(CWnd* pOldWnd)
{
pOldWnd = NULL;
m_WaveEditCtrl.SetCaret();
}
void CWaveEditorView::OnKillFocus(CWnd* pNewWnd)
{
pNewWnd = NULL;
m_WaveEditCtrl.KillCaret();
}
void CWaveEditorView::OnTimer(UINT nIDEvent)
{
if (m_WaveEditCtrl.m_bStopped){
KillTimer(1);
m_bPlaying = FALSE;
m_bPaused = FALSE;
m_bStopped = TRUE;
m_WaveEditCtrl.m_bStopped = FALSE;
}
m_WaveEditCtrl.MoveCaret();
CFormView::OnTimer(nIDEvent);
}
void CWaveEditorView::OnFileNew()
{
// TODO: Add your command handler code here
}
void CWaveEditorView::OnFileOpen()
{
// TODO: Add your command handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -