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

📄 playfile.cpp

📁 三汇CTI示例程序源码
💻 CPP
字号:

// PlayFile.cpp : implementation file
//

#include "stdafx.h"
#include "Record.h"
#include "PlayFile.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////



CPlayFile::CPlayFile(CWnd* pParent /*=NULL*/)
	: CDialog(CPlayFile::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPlayFile)
	m_strFileName = _T("");
	//}}AFX_DATA_INIT
}


void CPlayFile::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPlayFile)
	DDX_Control(pDX, IDC_COMBO_PLAYFILE, m_cmbPlayFile);
	DDX_Text(pDX, IDC_EDIT_FILENAME, m_strFileName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPlayFile, CDialog)
	//{{AFX_MSG_MAP(CPlayFile)
	ON_BN_CLICKED(IDC_BUTTON_STOPPLAYFILE, OnButtonStopplayfile)
	ON_BN_CLICKED(IDC_BUTTON_CHOOSEFILE, OnButtonChoosefile)
	ON_BN_CLICKED(IDC_BUTTON_PLAYFILE, OnButtonPlayfile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPlayFile message handlers

BOOL CPlayFile::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	char szTmp[10];
	int nMaxCh;

	nMaxCh = SsmGetMaxCh();		//retrieve channel amounts declared in configuration file 
	if(nMaxCh == -1)
	{
		WriteLog("failed to call function SsmGetMaxCh()");
	}

	for(int ch=0, i=0; ch<nMaxCh; ch++)	
	{
		int nResult = SsmGetChType(ch);  //retrieve channel type 
		if(nResult == -1)
		{
			WriteLog("failed to call function SsmGetChType()");
		}
		else if((nResult != 20) && (nResult != -1))  //value "20" indicates that no module is installed on the stated channel 
		{							  
			m_cmbPlayFile.InsertString(i++, _itoa(ch, szTmp, 10));
		}
	}

	m_cmbPlayFile.SetCurSel(0);

	InitLab();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CPlayFile::OnButtonStopplayfile()  //stop playing
{
	// TODO: Add your control notification handler code here
	int nCurLine;
	char szErrMsg[200];
	char sz[10];

	memset(sz, 0, sizeof(char)*10);
	m_cmbPlayFile.GetLBText(m_cmbPlayFile.GetCurSel(), sz);
	nCurLine = atoi(sz);
	//stop playing 
    if((SsmCheckPlay(nCurLine)==0) && (SsmStopPlayFile(nCurLine)==-1) 
		|| (SsmCheckPlay(nCurLine)==-1))
	{ 
		SsmGetLastErrMsg(szErrMsg);  //retrieve error message
		AfxMessageBox(szErrMsg, MB_OK, 0);
	}		
}


void CPlayFile::OnButtonChoosefile() //select file to be played 
{
	// TODO: Add your control notification handler code here

	CFileDialog cf(1, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "File(*.wav)|*.wav|All File(*.*)|*.*|",NULL);
	char path[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, szCurrentPath);
	strcpy(path, szCurrentPath);
	cf.m_ofn.lpstrInitialDir = path;

	if(cf.DoModal() == IDOK)
	{
		strcpy(m_strFileName.GetBuffer(MAX_PATH), cf.GetPathName());
		UpdateData(FALSE);
		m_strFileName.ReleaseBuffer(-1);
	}		
}


void CPlayFile::OnButtonPlayfile()	//play file on stated channel 
{
	// TODO: Add your control notification handler code here
	int nCurLine;
	nCurLine = m_cmbPlayFile.GetCurSel();
	char *pFileName =(char *)(LPCTSTR)(m_strFileName);
	char szErrMsg[200];

    if(SsmPlayFile(nCurLine, pFileName, -1, 0, -1) == -1) //play file on stated channel 
	{
		SsmGetLastErrMsg(szErrMsg);  //retrieve error message 
		AfxMessageBox(szErrMsg, MB_OK, 0);
	}		
}

void CPlayFile::InitLab()
{	
	if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
	{
		//Chinese
		strLab[0].Format("放音");
		strLab[1].Format("放音通道");		
	}
	else
	{	//English
		strLab[0].Format("Playback");
		strLab[1].Format("Id of playing channel");
	}
	SetWinTextLab(this, IDC_STATIC_PLAY,	strLab[0]);
	SetWinTextLab(this, IDC_STATIC_PLAYCH,	strLab[1]);
}

⌨️ 快捷键说明

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