📄 indlg.cpp
字号:
// InDlg.cpp : implementation file
//////////////////////////////////////////////////////////////////////
// Copyright 2000. Moe Wheatley AE4JY <ae4jy@mindspring.com>
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
////
#include "stdafx.h"
#include "pathsim.h"
#include "InDlg.h"
#include "pathsimdoc.h"
#include "wave.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInDlg dialog
CInDlg::CInDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInDlg)
m_InputSelect = 0;
//}}AFX_DATA_INIT
}
void CInDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInDlg)
DDX_Control(pDX, IDC_INFILEINFO, m_InFileInfoCtrl);
DDX_Control(pDX, IDC_INFILESEL, m_InFileSelectCtrl);
DDX_Control(pDX, IDC_INFILENAME, m_InFileNameCtrl);
DDX_Radio(pDX, IDC_SOUNDIN, m_InputSelect);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInDlg, CDialog)
//{{AFX_MSG_MAP(CInDlg)
ON_BN_CLICKED(IDC_INFILESEL, OnInfilesel)
ON_BN_CLICKED(IDC_SOUNDIN, OnSoundin)
ON_BN_CLICKED(IDC_WAVEIN, OnWavein)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInDlg message handlers
BOOL CInDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(m_InputSelect==USE_SOUNDCARD)
{
m_InFileNameCtrl.EnableWindow(FALSE);
m_InFileInfoCtrl.EnableWindow(FALSE);
m_InFileSelectCtrl.EnableWindow(FALSE);
}
m_InFileNameCtrl.SetWindowText(m_InFilePath);
m_InFileInfoCtrl.SetWindowText(m_InFileInfo);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInDlg::OnInfilesel()
{
// handler code here for getting Input filename
CString sFilter = "Wave Files (*.wav)|*.wav||";
CFileDialog Dlgfile( TRUE, "wav", m_InFilePath,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
(LPCTSTR)sFilter, this );
m_InFileLength = 0;
if( Dlgfile.DoModal() == IDOK)
{
m_InFilePath = Dlgfile.GetPathName();
m_InFileName = Dlgfile.GetFileName();
m_InFileInfo = GetFileInfo(m_InFilePath);
}
m_InFileNameCtrl.SetWindowText(m_InFilePath);
m_InFileInfoCtrl.SetWindowText(m_InFileInfo);
}
void CInDlg::OnSoundin()
{
m_InFileNameCtrl.EnableWindow(FALSE);
m_InFileInfoCtrl.EnableWindow(FALSE);
m_InFileSelectCtrl.EnableWindow(FALSE);
}
void CInDlg::OnWavein()
{
m_InFileNameCtrl.EnableWindow(TRUE);
m_InFileInfoCtrl.EnableWindow(TRUE);
m_InFileSelectCtrl.EnableWindow(TRUE);
}
CString CInDlg::GetFileInfo(CString path)
{
INT ErrorCode;
DWORD FileLength;
CWave TWave;
CString info = _T("Unknown error");
WAVEFORMATEX wfx;
ErrorCode = TWave.InOpen( &path, &wfx,0, &FileLength );
TWave.InClose();
if( !ErrorCode )
{
if( (wfx.nSamplesPerSec != 8000) ||
(wfx.nChannels != 1) ||
(wfx.wBitsPerSample != 16) )
{
info = _T("* Not 16 bit,8KHz,Mono");
}
else
{
m_InFileLength = FileLength;
info.Format("%10.1fKS %5.1fMin", (float)FileLength/1000,
(float)FileLength/(8000.0*60.0) );
}
}
else
{
switch( ErrorCode ){
case WAVIN_ERR_OPEN:
info = _T("* Can't Open File");
break;
case WAVIN_ERR_NOTWAVE:
info = _T("* Not a Wave File");
break;
case WAVIN_ERR_INVALID:
info = _T("* Invalid Wave File");
break;
case WAVIN_ERR_NODATA:
info = _T("* No Data in Wave File");
break;
case WAVIN_ERR_NOTSUPPORTED:
info = _T("* Not Supported Wave Type in");
break;
}
}
return info;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -