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

📄 shr_stateevent_vcdlg.cpp

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

#include "stdafx.h"
#include "SHR_StateEvent_VC.h"
#include "SHR_StateEvent_VCDlg.h"
#include "../../../../api/vc6.0/inc/Shpa3api.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)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSHR_StateEvent_VCDlg dialog

CSHR_StateEvent_VCDlg::CSHR_StateEvent_VCDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSHR_StateEvent_VCDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSHR_StateEvent_VCDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSHR_StateEvent_VCDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSHR_StateEvent_VCDlg)
	DDX_Control(pDX, IDC_COMBO1, m_CurLine);
	DDX_Control(pDX, IDC_LIST_TRK, m_ListCh);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSHR_StateEvent_VCDlg, CDialog)
	//{{AFX_MSG_MAP(CSHR_StateEvent_VCDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON_SetListen, OnBUTTONSetListen)
	ON_BN_CLICKED(IDC_BUTTON_UnSetListen, OnBUTTONUnSetListen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSHR_StateEvent_VCDlg message handlers

BOOL CSHR_StateEvent_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
	MaxLine = 0; 
	
	if (InitCtiSystem() == FALSE)
	{
		PostQuitMessage(0);
		return FALSE;
	}
	
	InitChannelState();                           
	InitChannelList();                             

	SetTimer(10, 100, NULL );
	EVENT_SET_INFO EventSet;				       
	EventSet.dwWorkMode = EVENT_MESSAGE;         
	EventSet.lpHandlerParam = this->GetSafeHwnd(); 
	if(SsmSetEvent(-1, -1, TRUE, &EventSet) == -1) 
	{
		SsmGetLastErrMsg(szErrMsg);				  
		AfxMessageBox(szErrMsg, MB_OK, 0);
		WriteLog(szErrMsg);                        
	}

	if((nTimer=SsmStartTimer(200, 1)) == -1)             
	{
		SsmGetLastErrMsg(szErrMsg);
		AfxMessageBox(szErrMsg, MB_OK, 0);
		WriteLog(szErrMsg);
	}

	ListenChannel = MaxLine;
	char szTmp[100];
	int reChState;
	for(int ch=0; ch<MaxLine; ch++)	
	{		
		_snprintf(szTmp, 100, "%d", ch);
		szTmp[99] = '\0';
		m_CurLine.InsertString(ch, szTmp);
		reChState = SsmGetChState(ch);
		if(reChState == -1)
		{
			SsmGetLastErrMsg(ChannelState[ch].pErrMsg);
			WriteLog(ChannelState[ch].pErrMsg);
		}
		if(reChState == 0)
		{
			ChannelState[ch].WorkState = CH_IDLE;
		}
    }
	m_CurLine.SetCurSel(0);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

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


void CSHR_StateEvent_VCDlg::InitChannelList()
{
	int reGetChType;
	static int VolumeWidth[10]={30, 60, 60, 60, 80, 100, 55, 55, 55};
    LV_COLUMN lv;
	lv.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
	
	lv.iSubItem = 0;
	lv.pszText = "Channel";
	lv.cx = VolumeWidth[0];
	m_ListCh.InsertColumn(0, &lv);

	lv.cx = VolumeWidth[1];
	lv.pszText = "ChannelState";
	lv.iSubItem = 1;
	m_ListCh.InsertColumn(1, &lv);

	lv.cx = VolumeWidth[2];
	lv.pszText = "ListenState";
	lv.iSubItem = 2;
	m_ListCh.InsertColumn(2, &lv);

	lv.cx = VolumeWidth[3];
	lv.pszText = "RecState";
	lv.iSubItem = 3;
	m_ListCh.InsertColumn(3, &lv);

	lv.cx = VolumeWidth[4];
	lv.pszText = "Number";
	lv.iSubItem = 4;
	m_ListCh.InsertColumn(4, &lv);

	lv.cx = VolumeWidth[5];
	lv.pszText = "LCDInfo";
	lv.iSubItem = 5;
	m_ListCh.InsertColumn(5, &lv);

	lv.cx = VolumeWidth[6];
	lv.pszText = "CallDirection";
	lv.iSubItem = 6;
	m_ListCh.InsertColumn(6, &lv);

	lv.cx = VolumeWidth[7];
	lv.pszText = "Volume";
	lv.iSubItem = 7;
	m_ListCh.InsertColumn(7, &lv);

	lv.cx = VolumeWidth[8];
	lv.pszText = "Time";
	lv.iSubItem = 8;
	m_ListCh.InsertColumn(8, &lv);
   
    char ItemIndex[3];
	for(int i=0; i<MaxLine; i++)
	{
		reGetChType = SsmGetChType(i); 
		if(reGetChType == -1)
		{
			SsmGetLastErrMsg(ChannelState[i].pErrMsg); 
			WriteLog(ChannelState[i].pErrMsg); 
		}

		if(reGetChType == 12)
		{
			wsprintf(ItemIndex, "%d", i);
            m_ListCh.InsertItem(i, ItemIndex);
		}
	}
}//InitChannelList End


void CSHR_StateEvent_VCDlg::InitChannelState()
{
	int reGetChType;
	for(int i=0; i<MaxLine; i++)
	{
		reGetChType = SsmGetChType(i);
		if(reGetChType == -1)
		{
			SsmGetLastErrMsg(ChannelState[i].pErrMsg);
			WriteLog(ChannelState[i].pErrMsg);
		}
		
		if(reGetChType == 12)
		{
		    ChannelState[i].WorkState = CH_OUTLINE;    
			ChannelState[i].IsListen = UNLISTEN;       
            ChannelState[i].IsRecord = UNRECORD;       
			ChannelState[i].pCallerId[0] = '\0';        
		    ChannelState[i].Lcd[0] = '\0' ;	           
			ChannelState[i].Dir = UNKNOWN ;            
			ChannelState[i].Volume = 0 ;              
            ChannelState[i].dwTimeOutCounter = 0;       
 		}
	}
}//InitChannelState End


bool CSHR_StateEvent_VCDlg::InitCtiSystem()
{
	int nIsSsmStartCtiOK = SsmStartCti("ShConfig.ini", "ShIndex.ini");
	if(nIsSsmStartCtiOK != 0)
	{
		SsmGetLastErrMsg(szErrMsg);
		AfxMessageBox(szErrMsg, MB_OK, 0);
		WriteLog(szErrMsg);
		return FALSE;
	}


	if(SsmGetMaxUsableBoard() != SsmGetMaxCfgBoard())
	{
		SsmGetLastErrMsg(szErrMsg);
		AfxMessageBox(szErrMsg, MB_OK, 0);
		WriteLog(szErrMsg);
	}

	if((MaxLine=SsmGetMaxCh()) == -1) 
	{
		SsmGetLastErrMsg(szErrMsg);
		AfxMessageBox(szErrMsg, MB_OK, 0);
		WriteLog(szErrMsg);
	}

	return TRUE;
}//InitCtiSystem End


LRESULT CSHR_StateEvent_VCDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	int nEvent,nEChState,ch;
	int reChkRecToFile;
	char recFile[256];

	int ChState = -1; 
	
    if(message > WM_USER)
	{
		nEvent = message - WM_USER;
		ch = wParam;
		nEChState = (int)(lParam & 0xFFFF);
		switch(ChannelState[ch].WorkState) 
		{
		case CH_IDLE: 
			switch(nEvent) 
			{

⌨️ 快捷键说明

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