?? recdlg.cpp
字號:
// RecDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SMS_duanxin.h"
#include "RecDlg.h"
#include "PDUdecoding.h"
#include "SendDlg.h"
#include "JustinIO.h"
#include "Message.h"
#include "SMS_duanxinDoc.h"
#include "SMS_duanxinView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static int m_sum;
/////////////////////////////////////////////////////////////////////////////
// CRecDlg dialog
CRecDlg::CRecDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRecDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRecDlg)
//}}AFX_DATA_INIT
}
void CRecDlg::DoDataExchange(CDataExchange* pDX)
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRecDlg)
DDX_Control(pDX, IDC_LIST2, m_recvlist);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRecDlg, CDialog)
//{{AFX_MSG_MAP(CRecDlg)
ON_BN_CLICKED(IDC_REC_BUTTON, OnRecButton)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_BN_CLICKED(IDC_RESPONSE, OnResponse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRecDlg message handlers
BOOL CRecDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_recvlist.InsertColumn(0, "號碼", LVCFMT_LEFT, 100);
m_recvlist.InsertColumn(1, "時間", LVCFMT_LEFT, 90);
m_recvlist.InsertColumn(2, "消息內容", LVCFMT_LEFT, 300);
m_recvlist.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
CFile file("收件箱.txt",CFile::modeRead);
CArchive ar(&file,CArchive::load);
int nsum;
int n=0;
CString no,time,text;
ar>>no>>nsum>>text;
ar>>no>>time>>text;
while(nsum--)
{
ar>>no>>time>>text;
no.TrimRight("\t\t");
time.TrimRight("\t\t");
text.TrimRight("\r\n");
m_recvlist.InsertItem(n,no);
m_recvlist.SetItemText(n,1,time);
m_recvlist.SetItemText(n,2,text);
n++;
}
ar.Flush();
ar.Close();
file.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRecDlg::OnRecButton()
{
// TODO: Add your control notification handler code here
SM_PARAM message[100]; //短信緩沖區
SM_BUFF buff; // 接收短消息列表的緩沖區
int smsNum;//短息條數
smsNum=gsmParseMessageList(message, &buff);
//顯示短信
for(int i=0;i<smsNum;i++)
{
m_recvlist.InsertItem(i+m_sum,message[i].TPA);
m_recvlist.SetItemText(i+m_sum,1,message[i].TP_SCTS);
m_recvlist.SetItemText(i+m_sum,2,message[i].TP_UD);
}
}
void CRecDlg::OnSave()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CFile sf("收件箱.txt",CFile::modeCreate | CFile::modeWrite);
CArchive ar(&sf,CArchive::store);
CString strout1,strout2,strout3,strout4,strout5;
m_sum = m_recvlist.GetItemCount();
strout1 = "號碼\t\t";
strout2 = "時間\t\t";
strout3 = "內容\r\n";
strout4 = "條數:\t\t";
strout5 = "\t\t\r\n";
ar<<strout4<<m_sum<<strout5;
ar<<strout1<<strout2<<strout3;
for(int i=0;i<m_sum;i++)
{
ar<<m_recvlist.GetItemText(i,0)+"\t\t"<<m_recvlist.GetItemText(i,1)+"\t\t"<<m_recvlist.GetItemText(i,2)+"\r\n";
}
ar.Flush();
ar.Close();
sf.Close();
}
void CRecDlg::OnDel()
{
// TODO: Add your control notification handler code here
POSITION pos = m_recvlist.GetFirstSelectedItemPosition();
//得到項目索引
m_index = m_recvlist.GetNextSelectedItem(pos);
if(m_index == -1)
{
AfxMessageBox("請選擇一項!");
return;
}
m_recvlist.DeleteItem(m_index);
UINT flag = LVIS_SELECTED|LVIS_FOCUSED;
m_recvlist.SetItemState(m_index,flag,flag);
}
void CRecDlg::OnResponse()
{
// TODO: Add your control notification handler code here
POSITION pos = m_recvlist.GetFirstSelectedItemPosition();
//得到項目索引
m_index = m_recvlist.GetNextSelectedItem(pos);
if(m_index == -1)
{
AfxMessageBox("請選擇一項!");
return;
}
CString response;
response=m_recvlist.GetItemText(m_index,0);
response.Left(2);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -