📄 recorddlg.cpp
字号:
// RecordDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Record.h"
#include "RecordDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
public:
void InitLabAbout();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRecordDlg dialog
CRecordDlg::CRecordDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRecordDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRecordDlg)
m_Constate = 1;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CRecordDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRecordDlg)
DDX_Control(pDX, IDC_COMBO_Cur_Line, m_CurLine);
DDX_Control(pDX, IDC_CHINFOLIST, m_ChList);
DDX_Radio(pDX, IDC_RADIO_ConState, m_Constate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRecordDlg, CDialog)
//{{AFX_MSG_MAP(CRecordDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_RADIO_ConState, OnRADIOConState)
ON_BN_CLICKED(IDC_RADIO_ConState1, OnRADIOConState1)
ON_BN_CLICKED(IDC_RADIO_ConState2, OnRADIOConState2)
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
ON_CBN_SELCHANGE(IDC_COMBO_Cur_Line, OnSelchangeCOMBOCurLine)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_BUTTON_LISTEN, OnButtonListen)
ON_BN_CLICKED(IDC_BUTTO_SETAGC, OnButtoSetagc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRecordDlg message handlers
BOOL CRecordDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//failed to load ShtCti driver
if(!InitCtiBoard())
{
PostQuitMessage(0);
return FALSE;
}
//set event_message programming mode
EVENT_SET_INFO EventSet;
EventSet.dwWorkMode = EVENT_MESSAGE;
EventSet.lpHandlerParam = this->GetSafeHwnd();
SsmSetEvent(-1, -1, TRUE, &EventSet);
char szTmp[10];
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 stated channel
{
m_CurLine.InsertString(i++, _itoa(ch, szTmp, 10));
}
}
m_CurLine.SetCurSel(0);
g_dwLanguageConversion = GetThreadLocale();
InitLab();
InitChList(); //initialize lists and channel parameters
return TRUE; // return TRUE unless you set the focus to a control
}
void CRecordDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CRecordDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CRecordDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CRecordDlg::InitCtiBoard(void)
{
char szCurPath[MAX_PATH]; //current path
char szShIndex[MAX_PATH]; //file ShIndex.ini
char szShConfig[MAX_PATH]; //file ShConfig.ini
CString CErrMsg; //error message
GetCurrentDirectory(MAX_PATH, szCurPath);
strcpy(szShIndex, szCurPath);
strcpy(szShConfig, szCurPath);
strcat(szShIndex, "\\ShIndex.ini");
strcat(szShConfig, "\\ShConfig.ini");
//deliver configuration file to ShCti driver and initialize system
if(SsmStartCti(szShConfig, szShIndex) == -1)
{
SsmGetLastErrMsg(CErrMsg.GetBuffer(300));//retrieve error message
AfxMessageBox(CErrMsg, MB_OK);
CErrMsg.ReleaseBuffer();
return FALSE;
}
//check whether number of boards initialized successfully equals that of boards set in configuration file
if(SsmGetMaxUsableBoard() != SsmGetMaxCfgBoard())
{
SsmGetLastErrMsg(CErrMsg.GetBuffer(300)); //retrieve error message
AfxMessageBox(CErrMsg, MB_OK);
CErrMsg.ReleaseBuffer();
return FALSE;
}
nMaxCh = SsmGetMaxCh(); //retrieve channel amounts declared in configuration file
if(nMaxCh == -1)
{
WriteLog("failed to call function SsmGetMaxCh()");
}
return TRUE;
}
void CRecordDlg::InitChList()
{
//initialize list
static int ColumnWidth[8] = {40, 95, 80, 60, 80, 100};
LV_COLUMN lvc;
lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
lvc.iSubItem = 0;
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
lvc.pszText = "通道" ;
else
lvc.pszText = "Channel ID" ;
lvc.cx = ColumnWidth[0];
m_ChList.InsertColumn(0, &lvc);
lvc.iSubItem = 1;
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
lvc.pszText = "通道状态";
else
lvc.pszText = "Channel state";
lvc.cx = ColumnWidth[1];
m_ChList.InsertColumn(1, &lvc);
lvc.iSubItem = 2;
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
lvc.pszText = "工作方式";
else
lvc.pszText = "Working mode";
lvc.cx = ColumnWidth[2];
m_ChList.InsertColumn(2, &lvc);
lvc.iSubItem = 3;
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
lvc.pszText = "启动键";
else
lvc.pszText = "Startup key";
lvc.cx = ColumnWidth[3];
m_ChList.InsertColumn(3, &lvc);
lvc.iSubItem = 4;
lvc.pszText = "RxDtmf";
lvc.cx = ColumnWidth[4];
m_ChList.InsertColumn(4, &lvc);
lvc.iSubItem = 5;
lvc.pszText = "CallerId";
lvc.cx = ColumnWidth[5];
m_ChList.InsertColumn(5, &lvc);
char dig[3];
for(int i=0; i<nMaxCh; i++)
{
int nResult = SsmGetChType(i); //retrieve channel type
if(nResult == -1)
{
WriteLog("failed to call function SsmGetChType()");
}
else if(nResult == 3) //if it is a recording channel
{
m_ChList.InsertItem(i, _itoa(i, dig, 10));
}
}
//initialize each on-board channel
for(int ch=0; ch<nMaxCh; ch++)
{
int nResult = SsmGetChType(ch); //retrieve channel type
if(nResult == -1)
{
WriteLog("failed to call function SsmGetChType()");
}
else if(nResult == 3) //if it is a recording channel
{
ChState[ch].nIndex = 0;
ChState[ch].WorkState = TRK_IDLE;
ChState[ch].ConState = VOLTAGE_CTRL;
ChState[ch].szDTMF[0] = 0;
ChState[ch].szCallerId[0] = 0;
nResult = SsmGetIgnoreLineVoltage(ch);
if(nResult == 0) //detect voltage
ChState[ch].bIgnoreLineVoltage = FALSE;
else if(nResult == 1)
ChState[ch].bIgnoreLineVoltage = TRUE;
//+++START+++ masked by sh , 2006-09-25
/*
if(SsmSetBargeInSens(ch, 8) == -1) //set BargeIn sensitivity to 8
{
WriteLog("failed to call function SsmSetBargeInSens");
}
if(SsmSetDtrmLineVoltage(ch, 12) == -1) //set detection voltage of hook state to 12V
{
WriteLog("failed to call function SsmSetDtrmLineVoltage()");
}
*/
//+++ END +++ masked by sh , 2006-09-25
}
else
{
ChState[ch].nIndex = 0;
ChState[ch].WorkState = -1;
ChState[ch].ConState = -1;
ChState[ch].szDTMF[0] = 0;
ChState[ch].szCallerId[0] = 0;
ChState[ch].bIgnoreLineVoltage = FALSE;
}
}
UpdateChList(); //update list
}
void CRecordDlg::UpdateChList()
{
//update list
CString strTrkstat;
char szNewStat[100];
char szOldStat[100];
int nResult;
int nIndex;
int i;
nIndex = 0;
for(i=0; i<nMaxCh; i++)
{
nResult = SsmGetChType(i); //retrieve channel type
if(nResult == -1)
{
WriteLog("failed to call function SsmGetChType()");
}
else if(nResult == 3) //if it is a recording channel
{
switch(ChState[i].WorkState)
{
case TRK_IDLE:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "空闲";
else
strTrkstat = "Idle";
}
break;
case TRK_PICKUP:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "摘机";
else
strTrkstat = "Off-hook";
}
break;
case TRK_RECORD:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "录音";
else
strTrkstat = "Recording";
}
break;
case TRK_OUTLINE:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "断线";
else
strTrkstat = "Off-line";
}
break;
case TRK_RINGING:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "振铃";
else
strTrkstat = "Ringing";
}
break;
}
m_ChList.GetItemText(nIndex, 1, szOldStat, 10);
if(strTrkstat != szOldStat)
{
m_ChList.SetItemText(nIndex, 1, strTrkstat.GetBuffer(30));
}
switch(ChState[i].ConState)
{
case VOICE_CTRL:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "声控";
else
strTrkstat = "Voice-control";
}
break;
case VOLTAGE_CTRL:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "压控";
else
strTrkstat = "Voltage-control";
}
break;
case DTMF_CTRL:
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
strTrkstat = "码控";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -