?? senddlg.cpp
字號:
// SendDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SMS_duanxin.h"
#include "SendDlg.h"
#include "PDUdecoding.h"
#include "RecDlg.h"
#include "JustinIO.h"
#include "PhonebookDlg.h"
#include "SettingDlg.h"
#include "SMS_duanxinDoc.h"
#include "SMS_duanxinView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int i=0;
int nsum1=0;
/////////////////////////////////////////////////////////////////////////////
// CSendDlg dialog
CSendDlg::CSendDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSendDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSendDlg)
//}}AFX_DATA_INIT
}
void CSendDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSendDlg)
DDX_Control(pDX, IDC_PHONENUM_LIST, m_selephone);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSendDlg, CDialog)
//{{AFX_MSG_MAP(CSendDlg)
ON_BN_CLICKED(IDC__SEND_BUTTON, OnSendButton)
ON_BN_CLICKED(IDC_PHONEBOOK, OnPhonebook)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSendDlg message handlers
BOOL CSendDlg::OnInitDialog()
{
CDialog::OnInitDialog();
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
CFile file("電話本.txt",CFile::modeRead);
CArchive ar(&file,CArchive::load);
int nsum;
CString no,name,phone;
ar>>no>>nsum>>phone;
ar>>no>>name>>phone;
while(nsum--)
{
ar>>no>>name>>phone;
phone.TrimRight("\r\n");
m_selephone.AddString(phone);
nsum1++;
}
ar.Flush();
ar.Close();
file.Close();
m_selephone.SetCurSel(-1);//初始選擇
TP_PID=0;
return TRUE;
}
//發送控件
void CSendDlg::OnSendButton()
{
// TODO: Add your control notification handler code here
//獲得用戶的輸入信息
CString desPhoneNum;
CString smsContent;
CString m_SMSC = "13800716500";
int smsLength;
//CSettingDlg set;
//CSMS_duanxinApp theApp;
SM_PARAM smParam;
UpdateData(true);
//GetDlgItemText(IDC_PHONENUM_LIST,desPhoneNum);
GetDlgItemText(IDC_SMSCONTENT_EDIT,smsContent);
// m_SMSC = set.m_strSmsc;
//smsLength = strlen(smsContent);
/* //檢查號碼
if(desPhoneNum.GetLength() < 11)
{
AfxMessageBox("請輸入正確的號碼!");
m_selephone.SetFocus();
m_selephone.SetEditSel(-1,0);
return;
}*/
//檢查短消息內容是否為空,或超長
CString strUnicode;
WCHAR wchar[1024];
smsLength= MultiByteToWideChar(CP_ACP,0,smsContent,-1,wchar,1024);
if(smsLength <= -1)
{
AfxMessageBox("請輸入消息內容!");
m_selephone.SetFocus();
m_selephone.SetEditSel(-1,0);
return;
}
else if(smsLength > 70)
{
AfxMessageBox("消息內容太長,無法發送!");
m_selephone.SetFocus();
m_selephone.SetEditSel(-1,0);
return;
}
// m_SMSC="13800716500"; TP_PID=0;
//填充SM_PARAM結構體內容
sprintf(smParam.SCA, "%s",(LPCSTR)m_SMSC); // 短消息服務中心號碼(SMSC地址)
//sprintf(smParam.TPA, "%s",(LPCSTR)desPhoneNum); // 目標號碼(TP-DA)
sprintf(smParam.TP_UD,"%s",(LPCSTR)smsContent); //發送的消息內容(TP_UD)
smParam.TP_PID=TP_PID; // 用戶信息協議標識(TP-PID)
smParam.TP_DCS = GSM_UCS2; // 用戶信息編碼方式(TP-DCS)
//OpenComm(theApp.m_strPort, theApp.m_strRate, NOPARITY, 8, ONESTOPBIT);
if(AfxMessageBox("確定發送嗎?", MB_YESNO) == IDYES)
{
//發送短消息
for(int j=0;j<nsum1;j++)
{
CString strtemp=m_selephone.SetCurSel(j);
m_selephone.GetLBText(j,strtemp);
GetDlgItemText(IDC_PHONENUM_LIST,desPhoneNum);
sprintf(smParam.TPA, "%s",(LPCSTR)desPhoneNum); //目標號碼(TP-DA)
gsmSendMessage(&smParam);
//Sleep(500);//睡眠500ms
}
CloseComm();
}
}
//打開通信錄,添加聯系人
void CSendDlg::OnPhonebook()
{
// TODO: Add your control notification handler code here
//提取所選列表項號碼列內容,放入聯系人列表中
CPhonebookDlg teleadd;
teleadd.DoModal();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -