📄 mylistview.cpp
字号:
// MyListView.cpp : implementation file
//
#include "stdafx.h"
#include "短信群发.h"
#include "MyListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyListView
IMPLEMENT_DYNCREATE(CMyListView, CListView)
CMyListView::CMyListView()
{
}
CMyListView::~CMyListView()
{
}
BEGIN_MESSAGE_MAP(CMyListView, CListView)
//{{AFX_MSG_MAP(CMyListView)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyListView drawing
void CMyListView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CMyListView diagnostics
#ifdef _DEBUG
void CMyListView::AssertValid() const
{
CListView::AssertValid();
}
void CMyListView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyListView message handlers
BOOL CMyListView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl& theCtrl = GetListCtrl();
theCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
DWORD dwStyle = GetWindowLong(theCtrl.m_hWnd,GWL_STYLE);
dwStyle |= LVS_REPORT;
SetWindowLong(theCtrl.m_hWnd,GWL_STYLE,dwStyle);
GetListCtrl().InsertColumn(0, "电话号码", LVCFMT_LEFT, 80);
GetListCtrl().InsertColumn(1, "发送时间", LVCFMT_LEFT, 80);
GetListCtrl().InsertColumn(2,"状态",LVCFMT_LEFT,80);
GetListCtrl().InsertColumn(3,"内容",LVCFMT_LEFT,80);
}
void CMyListView::OnTimer(UINT nIDEvent)
{
if(nIDEvent == 1)
{
SM_PARAM SmParam;
CString strTime;
CString strNumber;
CString strContent;
CListCtrl& ListCtrl = GetListCtrl();
// 取接收到的短消息
if(theApp.m_pSmsTraffic->GetRecvMessage(&SmParam))
{
// 取短消息信息
strNumber = SmParam.TPA;
strContent = SmParam.TP_UD;
strTime = "20" + CString(&SmParam.TP_SCTS[0],2)
+ "-" + CString(&SmParam.TP_SCTS[2],2)
+ "-" + CString(&SmParam.TP_SCTS[4],2)
+ " " + CString(&SmParam.TP_SCTS[6],2)
+ ":" + CString(&SmParam.TP_SCTS[8],2)
+ ":" + CString(&SmParam.TP_SCTS[10],2);
// 去掉号码前的"86"
if(strNumber.Left(2) == "86") strNumber = strNumber.Mid(2);
// 最多保留200条
int nItemCount = ListCtrl.GetItemCount();
if(nItemCount >= 200)
{
ListCtrl.DeleteItem(0);
nItemCount--;
}
// 插入新消息
ListCtrl.InsertItem(nItemCount, strNumber);
ListCtrl.SetItemText(nItemCount, 1, strTime);
ListCtrl.SetItemText(nItemCount,2,"接收");
ListCtrl.SetItemText(nItemCount, 3, strContent);
ListCtrl.EnsureVisible(nItemCount, FALSE);
}
}
else
{
// other timers
CListView::OnTimer(nIDEvent);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -