⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 receive.cpp

📁 网络短息平台的开发与设计
💻 CPP
字号:
// Receive.cpp : implementation file
//

#include "stdafx.h"
#include "Send.h"
#include "Receive.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CReceive dialog


CReceive::CReceive(CWnd* pParent /*=NULL*/)
	: CDialog(CReceive::IDD, pParent)
{
	//{{AFX_DATA_INIT(CReceive)
	m_strDphone = _T("");
	m_strDtime = _T("");
	m_strDcontent = _T("");
	//}}AFX_DATA_INIT
}


void CReceive::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CReceive)
	DDX_Control(pDX, IDC_LIST1, m_ListBx);
	DDX_Text(pDX, IDC_EDIT1, m_strDphone);
	DDX_Text(pDX, IDC_EDIT2, m_strDtime);
	DDX_Text(pDX, IDC_EDIT3, m_strDcontent);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CReceive, CDialog)
	//{{AFX_MSG_MAP(CReceive)
	ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CReceive message handlers

CString CReceive::NumberDecode(CString phone)
{
	CString strphone;
    char ch;
	int i;
    for(i=0;i<phone.GetLength();i+=2)
	{
	   ch=phone.GetAt(i);
	   strphone+=phone.GetAt(i+1);
       strphone+=ch;
	}
    return strphone;

}

CString CReceive::ContentDecode(CString content)
{
	WCHAR wchar[150]; 
	int j=0;
    int nSrcLength=content.GetLength();
	for(int i=0; i<nSrcLength; i+=4)
    {   
		char buf1=content.GetAt(i);
        if(buf1>'9') buf1-=7;
		char buf2=content.GetAt(i+1);
        if(buf2>'9') buf2-=7;
		char buf3=content.GetAt(i+2);
        if(buf3>'9') buf3-=7;
		char buf4=content.GetAt(i+3);
        if(buf4>'9') buf4-=7;
        wchar[j]=(buf4-48);
        wchar[j]|=(buf3-48)<<4;
		wchar[j]|=(buf2-48)<<8;
		wchar[j]|=(buf1-48)<<12;
		j++;

    }
	char strc[300];
	int nLength=::WideCharToMultiByte(CP_ACP, 0, wchar, nSrcLength/4, strc, 150, NULL, NULL);
    strc[nLength]='\0';
	return strc;
}

BOOL CReceive::OnInitDialog() 
{
	CDialog::OnInitDialog();
 	char *pbuffer1,*pbuffer2;
	int k=0;
	pbuffer1=Rpdu.GetBuffer(0);
	while(pbuffer1=strstr(pbuffer1,"+CMGL:"))
	{
	   CString Rtime;
       CString Rphone;
       CString Rcontent;
	   CString Buffer;
       pbuffer1=strstr(pbuffer1,"\r\n");
       pbuffer1+=22;
       Buffer+=*pbuffer1++;
       Buffer+=*pbuffer1++;
	   pbuffer1+=2;
	   int Acount=strtol(Buffer,&pbuffer2,16);
       for(int i=0;i<((Acount%2)+Acount);i++)
	   {
          Rphone+=*pbuffer1++;
	   }
       Rphone=NumberDecode(Rphone);
       Rphone=Rphone.Left(Acount);
	   pbuffer1+=2;
	   Buffer.Empty();
       Buffer+=*pbuffer1++;
       Buffer+=*pbuffer1++;
       int code=strtol(Buffer,&pbuffer2,16);
       for(i=0;i<14;i++)
	   {
         Rtime+=*pbuffer1++;
	   }
       Rtime=NumberDecode(Rtime);
       Buffer.Empty();
       Buffer+=*pbuffer1++;
       Buffer+=*pbuffer1++;
	   int count=strtol(Buffer,&pbuffer2,16);
	   for(i=0;i<count*2;i++)
	   {
         Rcontent+=*pbuffer1++;
	   } 
       Rcontent=ContentDecode(Rcontent);
	   int nIndex=m_ListBx.AddString(Rphone);
	   SMsg sm;
	   sm.Rcontent=Rcontent;
	   sm.Rphone=Rphone;
	   sm.Rtime="20"+Rtime.Left(2)+"/"+Rtime.Mid(2,2)+"/"+Rtime.Mid(4,2)+" "+Rtime.Mid(6,2)+":"+Rtime.Mid(8,2)+":"+Rtime.Mid(10,2);
	   m_ListBx.SetItemDataPtr(nIndex,new SMsg(sm));

	}
  	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CReceive::OnSelchangeList1() 
{
  int nIndex=m_ListBx.GetCurSel();
  if(nIndex!=LB_ERR)
  {
    SMsg *psm=(SMsg *)m_ListBx.GetItemDataPtr(nIndex);
	m_strDphone=psm->Rphone;
	m_strDtime=psm->Rtime;
	m_strDcontent=psm->Rcontent;
	UpdateData(FALSE);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -