?? replysmsdlg.cpp
字號:
// ReplySMSDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SIMTOOL.h"
#include "ReplySMSDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CReplySMSDlg dialog
extern CSIMTOOLApp theApp;
CReplySMSDlg::CReplySMSDlg(CWnd* pParent /*=NULL*/)
: CDialog(CReplySMSDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CReplySMSDlg)
m_Center = _T("");
m_SMS = _T("");
m_Tonum = _T("");
//}}AFX_DATA_INIT
}
void CReplySMSDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReplySMSDlg)
DDX_Control(pDX, IDC_INFO, m_Info);
DDX_Text(pDX, IDC_CENTER, m_Center);
DDX_Text(pDX, IDC_SMS, m_SMS);
DDV_MaxChars(pDX, m_SMS, 140);
DDX_Text(pDX, IDC_TONUM, m_Tonum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReplySMSDlg, CDialog)
//{{AFX_MSG_MAP(CReplySMSDlg)
ON_BN_CLICKED(IDC_BTNSEND, OnBtnsend)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReplySMSDlg message handlers
BOOL CReplySMSDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CReplySMSDlg::ShowWindow(TRUE);
m_Center = "+8613800100500";
m_Tonum = m_Num;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CReplySMSDlg::InfoCreate(CString sName, CString sNum, UINT nIDTemplate)
{
m_Name = sName;
m_Num = sNum;
CReplySMSDlg::Create(nIDTemplate);
}
void CReplySMSDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
CReplySMSDlg::DestroyWindow();
}
void CReplySMSDlg::OnBtnsend()
{
// TODO: Add your control notification handler code here
CString RetInfo, toadr, centernum, sms, sDevComm, sStatus, sAppComm;
unsigned char cUsc2[500];
char buf[250], cText[100], comm[20];
int iLen;
memset(comm, 0, 20);
memset(cText, 0, 100);
memset(buf, 0, 250);
memset(cUsc2, 0, 500);
sAppComm = theApp.GetAppComm();
sprintf(comm, "%s", sAppComm);
theApp.SetStatusText("正在尋找GPRS無線網絡設備,請稍后...");
m_Info.SetWindowText("正在尋找GPRS無線網絡設備,請稍后...");
theApp.SetDevText("");
sDevComm = theApp.OpenDev(comm, 9600);
if (sDevComm.GetLength() == 0)
{
theApp.SetStatusText("設備未被找到或端口未被初始化,正在嘗試初始化...");
m_Info.SetWindowText("設備未被找到或端口未被初始化,正在嘗試初始化...");
sDevComm = theApp.MultiBautOpenDev(comm);
if (sDevComm.GetLength() == 0)
{
theApp.mobile.CloseComm();
theApp.SetStatusText("沒有找到設備或端口波特率不匹配,請確定設備是否連接...");
m_Info.SetWindowText("沒有找到設備或端口波特率不匹配,請確定設備是否連接...");
MessageBox("沒有找到設備或端口波特率不匹配!", "AWS");
return;
}
else
{
theApp.SetStatusText("端口初始化完成,正在打開端口...");
m_Info.SetWindowText("端口初始化完成,正在打開端口...");
sDevComm = theApp.OpenDev(comm, 9600);
}
}
UpdateData(TRUE);
GetDlgItem(IDC_TONUM)->GetWindowText(toadr);
GetDlgItem(IDC_CENTER)->GetWindowText(centernum);
sms = m_SMS;
if (theApp.GetDevType() == "WAVECOM")
{
theApp.SetStatusText("");
sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
theApp.SetDevText(cText);
if (toadr.GetLength()==0 || centernum.GetLength()==0 || sms.GetLength()==0)
{
theApp.mobile.CloseComm();
MessageBox("請將信息填寫完整!", "AWS");
return;
}
m_Info.SetWindowText("發送短信息到");
theApp.mobile.CSCA(centernum);
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
theApp.mobile.CMGS(toadr, sms);
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
}
if (theApp.GetDevType() == "BENQ")
{
theApp.SetStatusText("");
sprintf(cText, "ADBON GPRS MODEM : %s/%d", sDevComm, 9600);
theApp.SetDevText(cText);
if (toadr.GetLength()==0 || centernum.GetLength()==0 || sms.GetLength()==0)
{
theApp.mobile.CloseComm();
MessageBox("請將信息填寫完整!", "AWS");
return;
}
m_Info.SetWindowText("發送短信息到("+m_Name+")"+m_Tonum);
sprintf(buf, "%s", sms);
theApp.mobile.CSCA(centernum);
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
iLen = strlen(buf);
theApp.mobile.gsmEncodeUcs2(buf, cUsc2, iLen);
theApp.mobile.gsmBytes2String(cUsc2, buf, iLen*2);
sms = buf;
theApp.mobile.CFUN();
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
theApp.mobile.COPS();
Sleep(10);
theApp.mobile.ReceiveInfo();
theApp.mobile.QCOPS();
Sleep(10);
theApp.mobile.ReceiveInfo();
theApp.mobile.CMGF("1"); // 短信格式: 0: PDU; 1: TEXT
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
theApp.mobile.CSCS("\"UCS2\"");
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
theApp.mobile.CSMP(17,168,0,8);
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
theApp.mobile.CMGS("\""+toadr+"\"", "00000000"+sms);
Sleep(10);
RetInfo = theApp.mobile.ReceiveInfo();
}
if (theApp.GetDevType() == "SAGEM MO1xx")
{
theApp.mobile.SetModuleType("SAGEM MO1xx");
MessageBox("SAGEM MO1xx", "AWS");
}
m_SMS = "";
UpdateData(FALSE);
theApp.mobile.CloseComm();
m_Info.SetWindowText("信息發送成功!");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -