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

📄 dtp_event_vcdlg.cpp

📁 三汇CTI示例程序源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DTP_Event_VCDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DTP_Event_VC.h"
#include "DTP_Event_VCDlg.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();

// 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)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CDTP_Event_VCDlg dialog

CDTP_Event_VCDlg::CDTP_Event_VCDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDTP_Event_VCDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDTP_Event_VCDlg)
	m_nRecFormat = 2;
	m_nCallFnMode = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDTP_Event_VCDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDTP_Event_VCDlg)
	DDX_Control(pDX, IDC_LIST_DTP, m_CicList);
	DDX_Control(pDX, IDC_COMBO_CIC, m_cmbCic);
	DDX_Radio(pDX, IDC_RADIO_CALL_IN, m_nRecFormat);
	DDX_Radio(pDX, IDC_RADIO_CIRCUIT, m_nCallFnMode);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDTP_Event_VCDlg, CDialog)
	//{{AFX_MSG_MAP(CDTP_Event_VCDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RADIO_CALL_IN, OnRadioCallIn)
	ON_BN_CLICKED(IDC_RADIO_CALL_OUT, OnRadioCallOut)
	ON_BN_CLICKED(IDC_RADIO_MIX, OnRadioMix)
	ON_CBN_SELCHANGE(IDC_COMBO_CIC, OnSelchangeComboCic)
	ON_WM_DESTROY()
	ON_BN_CLICKED(IDC_RADIO_CIRCUIT, OnRadioCircuit)
	ON_BN_CLICKED(IDC_RADIO_CH, OnRadioCh)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDTP_Event_VCDlg message handlers

BOOL CDTP_Event_VCDlg::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
	if(!InitCtiBoard())		
	{
		PostQuitMessage(0);
		return FALSE;
	}
	//Set event-driven mode
	EVENT_SET_INFO EventSet;		
	EventSet.dwWorkMode = EVENT_MESSAGE;	
	EventSet.lpHandlerParam = this->GetSafeHwnd();	
	if(SsmSetEvent(-1, -1, TRUE, &EventSet) == -1)
		MessageBox("Fail to call SsmSetEvent");
	if(SsmSetEvent(E_CHG_SpyState, -1, TRUE, &EventSet) == -1)
		MessageBox("Fail to call SsmSetEvent when setting E_CHG_SpyState");
	InitCircuitListCtrl();		//initialize list
	UpdateCircuitListCtrl();	//update list	
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDTP_Event_VCDlg::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 CDTP_Event_VCDlg::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 CDTP_Event_VCDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

//Initialize board
BOOL CDTP_Event_VCDlg::InitCtiBoard()
{
	char szCurPath[MAX_PATH];		//Current path
	char szShIndex[MAX_PATH];		//path to ShIndex.ini
	char szShConfig[MAX_PATH];		//path to ShConfig.ini
	CString CErrMsg;			    //error message
	GetCurrentDirectory(MAX_PATH, szCurPath);
	strcpy(szShIndex, szCurPath);
	strcpy(szShConfig, szCurPath);
	strcat(szShIndex, "\\ShIndex.ini");
	strcat(szShConfig, "\\ShConfig.ini");
	
	//load configuration file and initialize system
	if(SsmStartCti(szShConfig, szShIndex) == -1)
	{
		SsmGetLastErrMsg(CErrMsg.GetBuffer(300));//Get error message
		AfxMessageBox(CErrMsg, MB_OK);
		CErrMsg.ReleaseBuffer();
		return FALSE;
	}
	
	//Judge if the number of initialized boards is the same as
	//		   that of boards specified in the configuration file
	if(SsmGetMaxUsableBoard() != SsmGetMaxCfgBoard())
	{
		SsmGetLastErrMsg(CErrMsg.GetBuffer(300)); //Get error message	
		AfxMessageBox(CErrMsg, MB_OK);
		CErrMsg.ReleaseBuffer();
		return FALSE;
	}
	//Get the maximum number of the monitored circuits
	nMaxCic = SpyGetMaxCic();	  
	if(nMaxCic == -1)
	{
		MessageBox("Fail to call SpyGetMaxCic");
	}

	CString str;
	for(int i = 0; i < nMaxCic; i++)
	{
		memset(CicState[i].szCallInDtmf, 0, sizeof(char)*100);
		memset(CicState[i].szCallOutDtmf, 0, sizeof(char)*100);
		memset(CicState[i].szCallerId, 0, sizeof(char)*20);
		memset(CicState[i].szCalleeId, 0, sizeof(char)*20);
		CicState[i].nCicState = CIRCUIT_IDLE;
		CicState[i].nCallInIndex = 0;
		CicState[i].nCallOutIndex = 0;
		CicState[i].wRecDirection = MIX_RECORD;	    //mix-record
		CicState[i].nCallInCh = -1;	
		CicState[i].nCallOutCh = -1;
		str.Format("%d", i);
		m_cmbCic.InsertString(-1, str);
	}
	
	return TRUE;
}

//Initialize list
void CDTP_Event_VCDlg::InitCircuitListCtrl()
{
	static int ColumnWidth[6] = {40, 100, 100, 100, 120, 120};
 	LV_COLUMN lvc;
	lvc.mask =  LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;

	m_CicList.SetBkColor(RGB(0,0,0));
	m_CicList.SetTextColor(RGB(0,255,0));
	m_CicList.SetTextBkColor(RGB(0,0,0));

	DWORD dwExtendedStyle = m_CicList.GetExtendedStyle();
	dwExtendedStyle |= LVS_EX_FULLROWSELECT;
	dwExtendedStyle |= LVS_EX_GRIDLINES; 
	m_CicList.SetExtendedStyle(dwExtendedStyle);

	lvc.iSubItem = 0;
	lvc.pszText = "Cic" ;
	lvc.cx = ColumnWidth[0];
	m_CicList.InsertColumn(0, &lvc);

	lvc.iSubItem = 1;
	lvc.pszText = "CicState";
	lvc.cx = ColumnWidth[1];
	m_CicList.InsertColumn(1, &lvc);

	lvc.iSubItem = 2;
	lvc.pszText = "CallerId";
	lvc.cx = ColumnWidth[2];
	m_CicList.InsertColumn(2, &lvc);
    
	lvc.iSubItem = 3;
	lvc.pszText = "CalleeId";
	lvc.cx = ColumnWidth[3];
	m_CicList.InsertColumn(3, &lvc);   

	lvc.iSubItem = 4;
	lvc.pszText = "InComingCh:DTMF";
	lvc.cx = ColumnWidth[4];
	m_CicList.InsertColumn(4, &lvc); 

	lvc.iSubItem = 5;
	lvc.pszText = "OutgoingCh:DTMF";
	lvc.cx = ColumnWidth[5];
	m_CicList.InsertColumn(5, &lvc); 

	char dig[10];
	for(int i = 0; i < nMaxCic; i++)
	{
		m_CicList.InsertItem(i, _itoa(i, dig, 10));
	}
}

//Update list
void CDTP_Event_VCDlg::UpdateCircuitListCtrl()
{
	char szNewStat[100];
	char szOldStat[100];
	int nIndex;

	nIndex = 0;

⌨️ 快捷键说明

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