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

📄 duanxindlg.cpp

📁 用jsp做的能够实现简单的短信息发送回复的短消息系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DuanXinDlg.cpp : implementation file
//
 
#include "stdafx.h"
#include "DuanXin.h"
#include "DuanXinDlg.h"
#include "stdio.h"
#include  "string.h"
#include  "trim.h"
#include "MyRecordset.h"
#include "MyUser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CDuanXinDlg dialog

CDuanXinDlg::CDuanXinDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDuanXinDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDuanXinDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDuanXinDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDuanXinDlg)
	DDX_Control(pDX, IDC_CONNECT, m_Button);
	DDX_Control(pDX, IDC_LIST1, m_LIST);
	DDX_Control(pDX, IDC_PORT, m_PORT);
	DDX_Control(pDX, IDC_INFORMATION, m_INFORMATON);
	DDX_Control(pDX, IDC_ADDRESS, m_ADDRESS);
	DDX_Control(pDX, IDC_MOBILE, m_MOBILE);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDuanXinDlg, CDialog)
	//{{AFX_MSG_MAP(CDuanXinDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_ADD_MOBILE, OnAddMobile)
	ON_BN_CLICKED(IDC_REVER_MOBILE, OnReverMobile)
	ON_BN_CLICKED(IDC_CONNECT, OnConnect)
	ON_BN_CLICKED(IDC_OPEN_FILE_DIALOG, OnOpenFileDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDuanXinDlg message handlers
/************************************************************************************
*				功能描述:	数据的初始化
				输入参数:	无
				返回值:	无
				编写:		张明
				日期:		20060407
************************************************************************************/

BOOL CDuanXinDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
    char m_filename [128], m_tmp[100];
	// 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



	memset(m_filename, 0, 128) ;
	memset(m_tmp, 0, 100) ;
	strcpy(m_filename, ".\\chat.ini") ;

	GetPrivateProfileString("INIT", "INIT_IP", "", m_tmp, 100, m_filename);
	m_ADDRESS.SetWindowText(m_tmp) ;

	GetPrivateProfileString("INIT", "INIT_PORT", "", m_tmp, 100, m_filename);
	m_PORT.SetWindowText(m_tmp) ;



	p_head = new MOBILE;
	memset(p_head,0,sizeof(MOBILE));
	p_head->next =NULL;
	// TODO: Add extra initialization here
	MyCheckSecret();
	
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDuanXinDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDuanXinDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
/************************************************************************************
*				功能描述:	添加手机号码
				数据结构:	链表
				输入参数:	无
				返回值:	无
				编写:		张明
				日期:		20060407
************************************************************************************/

void CDuanXinDlg::OnAddMobile() 
{
	/*
	int i =0	;
	MOBILE *p_mobile=NULL;						//MOBILE为结构体
	memset(mobile,0,21);
	MOBILE *p_head1 = p_head;
//	char sztmp[21] ="\0";
	*/
	

	memset(mobile,0,21);
	CDuanXinApp *pApp=(CDuanXinApp *)AfxGetApp();
    CDuanXinDlg *pDlg=(CDuanXinDlg *)pApp->m_pMainWnd;
	pDlg->m_MOBILE.GetLine(0,mobile,16);
	Add_Mobile(mobile);

}

/************************************************************************************
*				功能描述:	删除手机号码
				数据结构:	链表
				输入参数:	无
				返回值:	无
				编写:		张明
				日期:		20060407
************************************************************************************/




void CDuanXinDlg::OnReverMobile() 
{
	// TODO: Add your control notification handler code here
	int i=0;
	i  =	AfxMessageBox("Are you sure delete y/n ",MB_YESNO,0);
	if(i == IDYES)
	{
		i = 0;
	}
	else
	{
		i=0;
		return ;
	}
	MOBILE * p_list_mobile , * p_privete;
	char number[21]= "\0";
	i = m_LIST.GetCurSel( );
	if(m_LIST.GetText(i,number) == LB_ERR)
	{
		AfxMessageBox(" get you select is error");
		return ;
	}
	p_list_mobile = p_head;
	m_LIST.DeleteString(i);
	while((strlen(p_list_mobile->sz_mobile)!=0)||(p_list_mobile->next !=NULL))
	{	
		
		if(strcmp(p_list_mobile->sz_mobile,number)==0)
		{
			if((p_list_mobile->next) == NULL)
			{
				
				delete p_list_mobile;
				p_privete->next =NULL;
				//AfxMessageBox(" delete success",MB_OK|MB_NO,0);
			}
			else
			{

				p_privete->next = p_list_mobile->next;
				delete p_list_mobile;
			//	AfxMessageBox(" delete success");
			}
			break;
		}
		p_privete = p_list_mobile;
		p_list_mobile = p_list_mobile->next;
	}
			
	
}
/************************************************************************************
*				功能描述:	函数实现与银信通的 数据连接
				输入参数:	无
				返回值:	无
				编写:		张明
************************************************************************************/

void CDuanXinDlg::OnConnect() 
{
	char	m_addr[21], m_port[8], m_tmp[128] ;
	char    information[502] = "\0";
	int		sock ,ret;
//	int		i , line_num ,b=0;
	char    send_message[MAX_LEN] ;
//	char	*p_line	;
	char	*p_message;	
	char	recv_message[100] ="\0";
	char	sz_judge[4] ="\0";
	MOBILE  * head1	= NULL	;
	/*
				head1 = p_head;
	while((strlen(head1->sz_mobile)!=0||head1->next !=NULL))
	{
		sprintf(information,"%s",head1->sz_mobile);
	    AfxMessageBox(information);
		head1 = head1->next;
		if(head1->next==NULL)
			break;
	}
	*/
			
	struct STSMSInfo
	{
	char	m_szAccount[21];
	char	m_szAccName[21];
	char	m_szMobile[16];
	char	m_szSend[2];
	char	m_szPay[2];
	char	m_szCod[5];
	char	m_szMess[501];
	char	m_szOther[21];
	char	m_szClient[2];
	};
	
	STSMSInfo	stSMSInfo;
	CDuanXinApp *pApp=(CDuanXinApp *)AfxGetApp();
	CDuanXinDlg *pDlg=(CDuanXinDlg *)pApp->m_pMainWnd;
	m_Button.ShowWindow(SW_HIDE);


		/*
	line_num = m_INFORMATON.GetLineCount();
	p_line  = information ;
	for( i=0 ; i<line_num ;i++)
	{
		
		m_INFORMATON.GetLine(i, p_line,22);
		//p_line = p_line + strlen(p_line);
		b = b+strlen(p_line);
		if(b>502-22)
			break;
		
	}
	p_line = NULL;
	*/
	m_INFORMATON.GetWindowText(information,500);
	if(p_head->next!=NULL)
	{
		head1 = p_head->next;
	}
	else
	{
		AfxMessageBox(" you did not write mobile number ");
		m_Button.ShowWindow(SW_SHOW);
		return;
	}
	
	while((strlen(head1->sz_mobile)!=0)||head1->next != NULL)
	{
	
	

		p_message = send_message;
		memset(send_message, 0, sizeof(send_message));
		memset(&stSMSInfo, 0 , sizeof(stSMSInfo));
	
		strcpy(stSMSInfo.m_szAccount, "60142810570185701");
		strcpy(stSMSInfo.m_szSend, "0");
		strcpy(stSMSInfo.m_szPay, "2");
		strcpy(stSMSInfo.m_szOther, "00010000000000000000");
		strcpy(stSMSInfo.m_szClient, "0");
	
		strcpy(stSMSInfo.m_szAccName, "Ming");
		/*  移动  */
		 
		strcpy(stSMSInfo.m_szMobile, head1->sz_mobile);
		
		strcpy(stSMSInfo.m_szMess,information);
		strcpy(stSMSInfo.m_szOther," ");

		strncpy(sz_judge,head1->sz_mobile,1);
		if((strcmp(sz_judge,"0")==0))
		
		{
			strcpy(stSMSInfo.m_szCod, "0003");
		}
		else 
		{
			strcpy(stSMSInfo.m_szCod, "0001");
		}

		/*  联通  */
		//strcpy(stSMSInfo.m_szMobile, "13070415621");
		//	strcpy(stSMSInfo.m_szCod, "0002");
		strcpy(p_message,stSMSInfo.m_szAccount);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szAccount),stSMSInfo.m_szAccName);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szAccName),stSMSInfo.m_szMobile);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szMobile), stSMSInfo.m_szSend);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szSend), stSMSInfo.m_szPay);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szPay), stSMSInfo.m_szCod);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szCod),stSMSInfo.m_szMess);
		strcpy(p_message=p_message+sizeof(stSMSInfo.m_szMess), stSMSInfo.m_szOther);
		strcpy(p_message =p_message+sizeof(stSMSInfo.m_szOther), stSMSInfo.m_szClient);
		p_message =	NULL;
		/*
		sprintf(send_message,"%21s",stSMSInfo.m_szAccount);

⌨️ 快捷键说明

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