⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wavedlg.cpp

📁 TAPI编程应用
💻 CPP
字号:
// wavedlg.cpp : implementation file
// (c) Dialogic corp 1995, 1996

#include "stdafx.h"
//#include "talker32.h"
#include "resource.h"
#include "wavedlg.h"
#include <mmsystem.h>
#include <mmreg.h>

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWaveDlg dialog


CWaveDlg::CWaveDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CWaveDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CWaveDlg)
	m_csFormat = _T("");
	m_nPlayFile = -1;
	m_csCustom = _T("");
	m_nCustom = 0;
	//}}AFX_DATA_INIT
}


void CWaveDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CWaveDlg)
	DDX_Control(pDX, IDC_PLAYFORMAT, m_btnPlayFormat);
	DDX_Control(pDX, IDC_FORMAT, m_ctlFormat);
	DDX_CBString(pDX, IDC_FORMAT, m_csFormat);
	DDX_Radio(pDX, IDC_PLAYFORMAT, m_nPlayFile);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CWaveDlg, CDialog)
	//{{AFX_MSG_MAP(CWaveDlg)
	ON_BN_CLICKED(IDC_PLAYFORMAT, OnPlayformat)
	ON_CBN_SELCHANGE(IDC_FORMAT, OnSelchangeFormat)
	ON_BN_CLICKED(IDC_RECFORMAT, OnRecformat)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CWaveDlg message handlers

BOOL CWaveDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_ctlFormat.AddString("1. ADPCM 4 bit 6 kHz");	
	m_ctlFormat.AddString("2. ADPCM 4 bit 8 kHz");	
	m_ctlFormat.AddString("3. MULAW 8 bit 6 kHz");	
	m_ctlFormat.AddString("4. MULAW 8 bit 8 kHz");	
	m_ctlFormat.AddString("5. MULAW 8 bit 11 kHz");	
	m_ctlFormat.AddString("6.  ALAW 8 bit 6 kHz");	
	m_ctlFormat.AddString("7.  ALAW 8 bit 8 kHz");	
	m_ctlFormat.AddString("8.  ALAW 8 bit 11 kHz");	
	m_ctlFormat.AddString("9.   PCM 8 bit 6 kHz");	
	m_ctlFormat.AddString("10.  PCM 8 bit 8 kHz");	
	m_ctlFormat.AddString("11.  PCM 8 bit 11 kHz");	
	GetPlayFormatID();	// get the format ID for play file
	m_btnPlayFormat.SetCheck(1);
	OnPlayformat();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CWaveDlg::OnPlayformat() 
{
	int nPlay = m_btnPlayFormat.GetCheck();
	if(nPlay) 
	{
		if(!m_csCustom.IsEmpty()) 
			m_nCustom = m_nPlayFileFormatID = m_ctlFormat.AddString(m_csCustom);
	}
	else if(m_nCustom)m_ctlFormat.DeleteString(m_nCustom);	// do not show
	m_ctlFormat.SetCurSel(nPlay ? m_nPlayFileFormatID : m_nFormatID);	
	m_ctlFormat.EnableWindow(!nPlay);
	
}

void CWaveDlg::OnRecformat() 
{
	OnPlayformat();
}

void CWaveDlg::OnSelchangeFormat() 
{
	m_nFormatID = m_ctlFormat.GetCurSel();	
}

// find out the format of the file selected to play
void CWaveDlg::GetPlayFormatID()
{
	WAVEFORMATEX WF;
	HMMIO hmmH;      
	MMCKINFO mmParent, mmSubchunk;
	DWORD dwFmtSize;
	int nBase=0, nMax=0, nOffset = -1;
	BOOL bWrong = FALSE;
	
	m_nPlayFileFormatID = 11;
    // Open wave file 
	if(m_csFileName.IsEmpty()) hmmH = 0;
    else hmmH = mmioOpen((LPSTR)(LPCTSTR)m_csFileName, NULL, MMIO_READ); //| MMIO_ALLOCBUF);
    if(!hmmH) 
	{
    	m_csCustom = "File not found";
    	return;
	}
    
    // Locate a 慠IFF

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -