📄 dialinfodlg.cpp
字号:
// DialInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SIMTOOL.h"
#include "DialInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CSIMTOOLApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDialInfoDlg dialog
CDialInfoDlg::CDialInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDialInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialInfoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDialInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialInfoDlg)
DDX_Control(pDX, IDC_TO, m_To);
DDX_Control(pDX, IDC_DIALINFO, m_DialInfo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialInfoDlg, CDialog)
//{{AFX_MSG_MAP(CDialInfoDlg)
ON_BN_CLICKED(IDC_BTNHANDUPPHONE, OnBtnhandupphone)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialInfoDlg message handlers
void CDialInfoDlg::OnBtnhandupphone()
{
// TODO: Add your control notification handler code here
theApp.mobile.HandUp();
theApp.mobile.CloseComm();
KillTimer(m_nTimer);
CDialInfoDlg::OnOK();
CDialInfoDlg::DestroyWindow();
}
BOOL CDialInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
char cTo[50], comm[20], cText[100];
CString sDevComm, sAppComm;
memset(cText, 0, 100);
memset(comm, 0, 20);
memset(cTo, 0, 50);
sprintf(cTo, "%s(%s)", m_Name, m_Num);
sAppComm = theApp.GetAppComm();
sprintf(comm, "%s", sAppComm);
CDialInfoDlg::ShowWindow(TRUE);
m_To.SetWindowText(cTo);
sDevComm = theApp.OpenDev(comm, 9600);
if (sDevComm.GetLength() == 0)
{
m_DialInfo.SetWindowText("设备未被找到或端口未被初始化,正在尝试初始化...");
sDevComm = theApp.MultiBautOpenDev(comm);
if (sDevComm.GetLength() == 0)
{
theApp.mobile.CloseComm();
m_DialInfo.SetWindowText("没有找到设备或端口波特率不匹配,请确定设备是否连接...");
return FALSE;
}
else
{
m_DialInfo.SetWindowText("端口初始化完成,正在打开端口...");
sDevComm = theApp.OpenDev(comm, 9600);
}
}
if (theApp.GetDevType() == "WAVECOM")
{
sprintf(cText, "正在拨打%s...", m_Num);
m_DialInfo.SetWindowText(cText);
theApp.mobile.DialUp(m_Num);
m_nTimer = SetTimer(1, 1000, 0);
}
if (theApp.GetDevType() == "SAGEM MO1xx")
{
theApp.mobile.SetModuleType("SAGEM MO1xx");
MessageBox("SAGEM MO1xx", "AWS");
}
if (theApp.GetDevType() == "BENQ")
{
sprintf(cText, "正在拨打%s...", m_Num);
m_DialInfo.SetWindowText(cText);
theApp.mobile.DialUp(m_Num);
m_nTimer = SetTimer(1, 1000, 0);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialInfoDlg::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_DialInfo.SetWindowText("拨叫");
break;
case AI_BUSY: // 对方电话忙
m_DialInfo.SetWindowText("对方电话忙,请稍后再拨");
break;
case AI_NOANSWER: // 对方电话没有应答
m_DialInfo.SetWindowText("对方电话没有应答");
break;
case AI_NOCARRIER: // 对方挂机
m_DialInfo.SetWindowText("对方已挂机");
break;
default:
break;
}
CDialog::OnTimer(nIDEvent);
}
void CDialInfoDlg::InfoCreate(CString sName, CString sNum, UINT nIDTemplate)
{
m_Name = sName;
m_Num = sNum;
CDialInfoDlg::Create(nIDTemplate);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -