📄 dialphonedlg.cpp
字号:
// DialPhoneDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SIMTOOL.h"
#include "DialPhoneDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialPhoneDlg dialog
extern CSIMTOOLApp theApp;
CDialPhoneDlg::CDialPhoneDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDialPhoneDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialPhoneDlg)
m_PhoneNum = _T("");
//}}AFX_DATA_INIT
}
void CDialPhoneDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialPhoneDlg)
DDX_Control(pDX, IDC_HANDUPBTN, m_HandUpBtn);
DDX_Control(pDX, IDC_BTNDIALPHONE, m_DialBtn);
DDX_Control(pDX, IDC_INFO, m_Info);
DDX_Text(pDX, IDC_PHONENUM, m_PhoneNum);
DDV_MaxChars(pDX, m_PhoneNum, 20);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialPhoneDlg, CDialog)
//{{AFX_MSG_MAP(CDialPhoneDlg)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BTNDIALPHONE, OnBtndialphone)
ON_BN_CLICKED(IDC_HANDUPBTN, OnHandupbtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialPhoneDlg message handlers
BOOL CDialPhoneDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialPhoneDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CString RetInfo;
int result;
RetInfo = theApp.mobile.ReceiveInfo();
if (RetInfo.GetLength() == 0)
{
return;
}
// 没有信息返回,退出
result = theApp.mobile.AnalyseRetInfo(RetInfo);
// 分析返回值
switch(result)
{
case AI_DIALUP: // 有电话拨出
m_Info.SetWindowText("拨叫");
break;
case AI_BUSY: // 对方电话忙
m_Info.SetWindowText("对方电话忙,请稍后再拨");
break;
case AI_NOANSWER: // 对方电话没有应答
m_Info.SetWindowText("对方电话没有应答");
break;
case AI_NOCARRIER: // 对方挂机
m_Info.SetWindowText("对方电话已挂机");
break;
default:
break;
}
CDialog::OnTimer(nIDEvent);
}
void CDialPhoneDlg::OnBtndialphone()
{
// TODO: Add your control notification handler code here
CString sDevComm, sAppComm;
char comm[20], cText[100];
memset(cText, 0, 100);
memset(comm, 0, 20);
sAppComm = theApp.GetAppComm();
sprintf(comm, "%s", sAppComm);
UpdateData(TRUE);
if (m_PhoneNum.GetLength() == 0)
{
m_Info.SetWindowText("请输入要拨打的电话号码");
GetDlgItem(IDC_PHONENUM)->SetFocus();
return;
}
sDevComm = theApp.OpenDev(comm, 9600);
if (sDevComm.GetLength() == 0)
{
m_Info.SetWindowText("设备未被找到或端口未被初始化,正在尝试初始化...");
sDevComm = theApp.MultiBautOpenDev(comm);
if (sDevComm.GetLength() == 0)
{
theApp.mobile.CloseComm();
m_Info.SetWindowText("没有找到设备或端口波特率不匹配,请确定设备是否连接...");
return;
}
else
{
m_Info.SetWindowText("端口初始化完成,正在打开端口...");
sDevComm = theApp.OpenDev(comm, 9600);
}
}
sprintf(cText, "正在拨打%s...", m_PhoneNum);
m_Info.SetWindowText(cText);
theApp.mobile.DialUp(m_PhoneNum);
m_nTimer = SetTimer(1, 1000, 0);
}
void CDialPhoneDlg::OnHandupbtn()
{
// TODO: Add your control notification handler code here
m_PhoneNum = "";
UpdateData(FALSE);
theApp.mobile.HandUp();
theApp.mobile.CloseComm();
KillTimer(m_nTimer);
CDialPhoneDlg::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -