www.pudn.com > sms-wavecom.rar > smsDlg.cpp


// smsDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "sms.h" 
#include "smsDlg.h" 
#include "Math.h" 
#include  "comm.h" 
#include "_sms.h" 
#include "dlg_connect.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSmsDlg dialog 
 
CSmsDlg::CSmsDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CSmsDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CSmsDlg) 
	m_message = _T(""); 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
} 
 
void CSmsDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSmsDlg) 
	DDX_Control(pDX, IDC_EDIT_MESSAGE, m_ctr_message); 
	DDX_Control(pDX, IDC_BUTTON_CHANGE_MESSAGE, m_bt_change_message); 
	DDX_Control(pDX, IDC_BUTTON_GET_MESSAGE, m_bt_get_message); 
	DDX_Control(pDX, IDC_BUTTON_GET_NUM, m_bt_get_number); 
	DDX_Control(pDX, IDC_STATIC_cnt, m_ctr_cnt); 
	DDX_Control(pDX, IDC_STATIC_num_tatol, m_ctr_num_all); 
	DDX_Control(pDX, IDC_PROGRESS, m_ctr_prog); 
	DDX_Control(pDX, IDC_BUTTON_SEND, m_bt_send); 
	DDX_Control(pDX, IDC_STATIC_NUM, m_ctr_num); 
	DDX_Control(pDX, IDC_LIST_MSG, m_ctr_msg); 
	DDX_Text(pDX, IDC_EDIT_MESSAGE, m_message); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CSmsDlg, CDialog) 
	//{{AFX_MSG_MAP(CSmsDlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_BN_CLICKED(IDC_BUTTON_GET_MESSAGE, OnButtonGetMessage) 
	ON_EN_CHANGE(IDC_EDIT_MESSAGE, OnChangeEditMessage) 
	ON_BN_CLICKED(IDC_BUTTON_CHANGE_MESSAGE, OnButtonChangeMessage) 
	ON_BN_CLICKED(IDC_BUTTON_GET_NUM, OnButtonGetNum) 
	ON_BN_CLICKED(IDC_BUTTON_SEND, OnButtonSend) 
	ON_WM_CLOSE() 
	ON_WM_DESTROY() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSmsDlg message handlers 
 
BOOL CSmsDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	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 
	 
	// TODO: Add extra initialization here 
	issend = 0 ; 
	 
	m_ctr_prog.SetStep(1); 
	char port[10] ; 
	GetPrivateProfileString("SYSTEM","COM","COM1",port,50,"./sms.ini"); 
	int nBaudRate = GetPrivateProfileInt("SYSTEM","BaudRate",9600,"./sms.ini"); 
	if( !OpenComm(port, nBaudRate, 0, 8, 0) ) 
//	if( !open_com() ) 
	{ 
		AfxMessageBox("串口打开失败,请检查配置文件!"); 
		::exit(0); 
	} 
	Cdlg_connect  dlg_connect; 
	dlg_connect.Create(IDD_DIALOG_connect,NULL); 
	dlg_connect.ShowWindow(SW_SHOW); 
	dlg_connect.RedrawWindow(); 
 
	CStdioFile sysfile; 
	CString str  ; 
	char buf[50]; 
	memset(buf,0,50); 
	int i=GetSystemDirectory(buf,50); 
	str.Format("%s\\smm.dll",buf); 
	i = sysfile.Open(str ,CFile::modeReadWrite|CFile::shareDenyNone,NULL); 
	if( i == 0 )  
	{ 
		sysfile.Open(str , CFile::modeCreate | CFile::modeWrite|CFile::shareDenyNone,NULL); 
		str = "0" ; 
		sysfile.WriteString(str); 
	} 
	else 
	{ 
		sysfile.ReadString(str); 
		sysfile.SeekToBegin(); 
		i = atoi(str.GetBuffer(0)); 
		i++; 
		if(i > 100) 
		{ 
			MessageBox("error"); 
			::exit(0); 
		} 
		str.Format("%04u",i); 
		sysfile.WriteString(str); 
	} 
	sysfile.Close(); 
	 
 
	if (!gsmInit()) 
	{ 
		AfxMessageBox("该端口上没有发现MODEM!\n请检查设备连接是否正确."); 
		::exit(0); 
	} 
	m_ctr_msg.SetExtendedStyle(LVS_EX_GRIDLINES ); 
	m_ctr_msg.InsertColumn(0,"卡号",LVCFMT_LEFT,100,100); 
	m_ctr_msg.InsertColumn(1,"状态",LVCFMT_LEFT,150,150); 
	 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CSmsDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// 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 CSmsDlg::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 CSmsDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
DWORD WINAPI thread_send_message(LPARAM lParam) 
{ 
	CSmsDlg *pdlg; 
	pdlg=(CSmsDlg *)lParam; 
	CString str,src_num; 
	CStdioFile num_file; 
	unsigned long lg; 
	char ans[128];		// 应答串 
	char number[14]; 
	unsigned char num_len; 
	unsigned int ms_sleep = GetPrivateProfileInt("SYSTEM","TIME",0,"./sms.ini"); 
	 
	if( !num_file.Open("number.txt",CFile::modeRead|CFile::shareDenyNone,NULL)) 
	{ 
		AfxMessageBox("号码未找到,请提取群发号码!"); 
		pdlg->issend = 0 ; 
		pdlg->m_bt_send.SetWindowText("开始发送"); 
		pdlg->m_bt_change_message.EnableWindow(TRUE); 
		pdlg->m_bt_get_number.EnableWindow(TRUE); 
		pdlg->m_bt_get_message.EnableWindow(TRUE); 
		pdlg->m_ctr_message.EnableWindow(TRUE); 
		return 0; 
	} 
 
	while((num_file.ReadString(src_num) != NULL) && ( pdlg->issend == 1 )) 
	{ 
		if(src_num.GetLength() == 11) 
		{ 
			if( pdlg->m_ctr_msg.GetItemCount() > 200 ) pdlg->m_ctr_msg.DeleteAllItems(); 
			pdlg->m_ctr_msg.InsertItem(0,src_num); 
			num_len=gsmInvertNumbers(src_num.GetBuffer(0),number,11); 
			memcpy(&pdlg->send_buf[pdlg->num_addr],number,num_len); 
			pdlg->m_ctr_msg.SetItemText(0,1,"正在发送..."); 
			WriteComm(pdlg->send_buf,strlen(pdlg->send_buf)); 
			memset(ans,0,sizeof(ans)); 
			num_len = ReadComm(ans, 18); 
			if(num_len == 0 ) num_len =ReadComm(ans, 20); 
			if(num_len == 0 )  
			{ 
				pdlg->m_ctr_msg.SetItemText(0,1,"设备超时"); 
			} 
			else 
			{ 
				if( strstr(ans,"OK") != NULL ) pdlg->m_ctr_msg.SetItemText(0,1,"发送成功"); 
				else  pdlg->m_ctr_msg.SetItemText(0,1,"发送失败"); 
			} 
		} 
		pdlg->m_ctr_prog.StepIt(); 
		pdlg->m_ctr_cnt.GetWindowText(str); 
		lg = atol(str); 
		lg++; 
		str.Format("%u",lg); 
		pdlg->m_ctr_cnt.SetWindowText(str); 
 
		Sleep(ms_sleep); 
	} 
	num_file.Close(); 
	pdlg->m_bt_send.SetWindowText("开始发送"); 
	pdlg->m_bt_change_message.EnableWindow(TRUE); 
	pdlg->m_bt_get_number.EnableWindow(TRUE); 
	pdlg->m_bt_get_message.EnableWindow(TRUE); 
	pdlg->m_ctr_message.EnableWindow(TRUE); 
	pdlg->issend = 0 ; 
	return 1 ; 
} 
bool CSmsDlg::open_com() 
{ 
/*	DCB dcb;		// 串口控制块 
	COMMTIMEOUTS timeouts = {	// 串口超时控制参数 
		100,				// 读字符间隔超时时间: 100 ms 
		1,					// 读操作时每字符的时间: 1 ms (n个字符总共为n ms) 
		500,				// 基本的(额外的)读超时时间: 500 ms 
		1,					// 写操作时每字符的时间: 1 ms (n个字符总共为n ms) 
		100};				// 基本的(额外的)写超时时间: 100 ms 
 
	char port[10] ; 
	GetPrivateProfileString("SYSTEM","COM","COM1",port,50,"./sms.ini"); 
 
	hComm = CreateFile(port,	// 串口名称或设备路径 
			GENERIC_READ | GENERIC_WRITE,	// 读写方式 
			0,				// 共享方式:独占 
			NULL,			// 默认的安全描述符 
			OPEN_EXISTING,	// 创建方式 
			0,				// 不需设置文件属性 
			NULL);			// 不需参照模板文件 
	 
	if(hComm == INVALID_HANDLE_VALUE) return FALSE;		// 打开串口失败 
 
	GetCommState(hComm, &dcb);		// 取DCB 
	int nBaudRate = GetPrivateProfileInt("SYSTEM","BaudRate",9600,"./sms.ini"); 
	dcb.BaudRate = nBaudRate; 
	dcb.ByteSize = 8; 
	dcb.Parity = 0; 
	dcb.StopBits = 1; 
	SetCommState(hComm, &dcb);		// 设置DCB 
	SetupComm(hComm, 4096, 1024);	// 设置输入输出缓冲区大小 
	SetCommTimeouts(hComm, &timeouts);	// 设置超时 
	*/	 
	return TRUE; 
 
} 
 
void CSmsDlg::OnButtonGetMessage()  
{ 
	// TODO: Add your control notification handler code here 
	GetPrivateProfileString("SYSTEM","MESSAGE","",m_message.GetBuffer(0),170,"./sms.ini"); 
	UpdateData(FALSE); 
	 
} 
 
void CSmsDlg::OnChangeEditMessage()  
{ 
	// TODO: If this is a RICHEDIT control, the control will not 
	// send this notification unless you override the CDialog::OnInitDialog() 
	// function and call CRichEditCtrl().SetEventMask() 
	// with the ENM_CHANGE flag ORed into the mask. 
	UpdateData(); 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CSmsDlg::OnButtonChangeMessage()  
{ 
	// TODO: Add your control notification handler code here 
	WCHAR wchar[1024]; 
	UpdateData(); 
	int nCount = ::MultiByteToWideChar(CP_ACP, 0, m_message, -1, wchar, 1024); 
	if(nCount <= 1) 
	{ 
		AfxMessageBox("请输入消息内容!"); 
		return; 
	} 
	else if(nCount > 71)		// 我们决定全部用UCS2编码,最大70个字符(半角/全角) 
	{ 
		AfxMessageBox("消息内容太长,请重新输入!"); 
		return; 
	} 
 
	if( WritePrivateProfileString("SYSTEM","MESSAGE",m_message,"./sms.ini") ) MessageBox("群发词修改成功!"); 
	else MessageBox("群发词修改失败!"); 
} 
DWORD WINAPI thread_get_number(LPARAM lParam) 
{ 
	CSmsDlg *pdlg; 
	pdlg=(CSmsDlg *)lParam; 
	unsigned int len; 
	unsigned long lg,cnt,num_cnt,lgtemp; 
	bool number[0xffff]; 
	 
	CStdioFile src_file,num_file; 
	CString src_file_name,src_num_temp,num_temp,str; 
	srand( (unsigned)time( NULL ) ); 
	pdlg->m_ctr_num.SetWindowText(""); 
	GetPrivateProfileString("SYSTEM","file","",src_file_name.GetBuffer(0),170,"./sms.ini"); 
	if( !src_file.Open(src_file_name,CFile::modeRead|CFile::shareDenyNone,NULL)) 
	{ 
		AfxMessageBox("号码文件未找到,请检查配置文件!"); 
		return 0; 
	} 
	pdlg->m_bt_get_number.EnableWindow(FALSE); 
	 
	num_file.Open("temp.txt",CFile::modeCreate | CFile::modeReadWrite|CFile::shareDenyNone,NULL); 
	cnt = 0 ; 
	while(src_file.ReadString(src_num_temp) != NULL) 
	{ 
		len = src_num_temp.GetLength() ; 
		if(( len > 3 ) && ( len < 12 ))  
		{ 
			if( len == 11 )  
			{ 
				src_num_temp = src_num_temp + "\n" ; 
				num_file.WriteString(src_num_temp); 
				cnt++; 
				str.Format("%u",cnt); 
				pdlg->m_ctr_num_all.SetWindowText(str); 
 
			} 
			else 
			{ 
				len = 11 - len ; 
				num_cnt = pow(10,len) ; 
				memset(number,0,sizeof(number)); 
				for( lg = 0 ; lg < num_cnt ; lg ++ ) 
				{ 
					lgtemp = lg ; 
					num_temp.Format("%i",lgtemp); 
					while( num_temp.GetLength() != len ) num_temp = "0" + num_temp ; 
					num_temp = src_num_temp + num_temp +"\n"; 
					num_file.WriteString(num_temp); 
					cnt++; 
					str.Format("%u",cnt); 
					pdlg->m_ctr_num_all.SetWindowText(str); 
				} 
			} 
		} 
	} 
	src_file.Close(); 
	unsigned long file_len = num_file.GetLength()/13; 
	pdlg->m_ctr_prog.SetRange(0,file_len); 
	num_temp.Format("%u",file_len); 
	pdlg->m_ctr_cnt.SetWindowText("0"); 
//以下生成随机文件 
	CStdioFile rand_file; 
	char *pdt ; 
	unsigned long total_length; 
 
	pdt = (char*)malloc(num_file.GetLength()); 
	num_file.SeekToBegin(); 
	total_length = num_file.GetLength() ; 
	num_file.ReadHuge(pdt , total_length ); 
	num_file.Close(); 
	srand( (unsigned)time( NULL ) ); 
	rand_file.Open("number.txt",CFile::modeCreate | CFile::modeWrite|CFile::shareDenyNone,NULL); 
	num_cnt = total_length  / 13 ; 
	total_length = num_cnt * 12 ; 
	lgtemp = 0 ; 
	pdlg->m_ctr_prog.SetRange32(0,num_cnt); 
	pdlg->m_ctr_prog.SetStep(1); 
	while(num_cnt > 0 ) 
	{ 
		cnt = rand() * (num_cnt -1); 
		cnt = cnt / RAND_MAX; 
		cnt = cnt * 12 ; 
		num_temp.Format("%s",&pdt[cnt]); 
		num_temp = num_temp.Left(11) + "\n" ; 
		rand_file.WriteString(num_temp) ; 
		num_cnt--; 
		total_length = total_length - 12 ; 
		memcpy(&pdt[cnt],&pdt[cnt+12],(total_length - cnt )); 
		lgtemp++; 
		str.Format("%u",lgtemp); 
		pdlg->m_ctr_cnt.SetWindowText(str); 
		pdlg->m_ctr_prog.StepIt(); 
	} 
	free(pdt); 
	rand_file.Close(); 
	num_file.Remove("temp.txt"); 
	pdlg->m_ctr_prog.SetPos(0); 
	pdlg->m_ctr_cnt.SetWindowText("0");	 
	pdlg->m_bt_send.EnableWindow(TRUE); 
	pdlg->m_bt_get_number.EnableWindow(TRUE); 
	return 1; 
} 
void CSmsDlg::OnButtonGetNum()  
{ 
	// TODO: Add your control notification handler code here 
	m_bt_send.EnableWindow(FALSE); 
	CreateThread(NULL,0,LPTHREAD_START_ROUTINE(thread_get_number),this,0,NULL); 
	m_ctr_prog.SetPos(0); 
	m_bt_get_message.SetFocus(); 
} 
 
void CSmsDlg::OnButtonSend()  
{ 
	// TODO: Add your control notification handler code here 
	CString bt; 
	m_bt_send.GetWindowText(bt); 
	if(bt == "开始发送") 
	{ 
 
		// 检查短消息内容是否空,或者超长 
 
		WCHAR wchar[1024]; 
		UpdateData(); 
		int nCount = ::MultiByteToWideChar(CP_ACP, 0, m_message, -1, wchar, 1024); 
		if(nCount <= 1) 
		{ 
			AfxMessageBox("请输入消息内容!"); 
			return; 
		} 
		else if(nCount > 71)		// 我们决定全部用UCS2编码,最大70个字符(半角/全角) 
		{ 
			AfxMessageBox("消息内容太长,无法发送!"); 
			return; 
		} 
		SM_PARAM SmParam; 
		memset(&SmParam, 0, sizeof(SM_PARAM)); 
 
		// 填充短消息结构 
		CString strSmsc ; 
		GetPrivateProfileString("SYSTEM","SMSC","8613010911500",strSmsc.GetBuffer(0),50,"./sms.ini"); 
		strcpy(SmParam.SCA, strSmsc); 
		strcpy(SmParam.TPA, "8613123456789"); 
		strcpy(SmParam.TP_UD, m_message); 
		SmParam.TP_PID = 0; 
		SmParam.TP_DCS = GSM_UCS2; 
		int nPduLength;		// PDU串长度 
		unsigned char nSmscLength;	// SMSC串长度 
		char cmd[16];		// 命令串 
		char pdu[512];		// PDU串 
		nPduLength = gsmEncodePdu(&SmParam, pdu);	// 根据PDU参数,编码PDU串 
		strcat(pdu, "\x01a");		// 以Ctrl-Z结束 
		gsmString2Bytes(pdu, &nSmscLength, 2);	// 取PDU串中的SMSC信息长度 
		nSmscLength++;		// 加上长度字节本身 
		// 命令中的长度,不包括SMSC信息长度,以数据字节计 
		sprintf(cmd, "AT+CMGS=%d\r", nPduLength / 2 - nSmscLength);	// 生成命令 
		send_buf[0]=0; 
		strcat(send_buf,cmd); 
		strcat(&send_buf[strlen(cmd)],pdu); 
		num_addr = strlen(cmd) + 28 ;	 
		h_send_message = CreateThread(NULL,0,LPTHREAD_START_ROUTINE(thread_send_message),this,0,NULL); 
		if( h_send_message != NULL ) issend = 1; 
		m_bt_send.SetWindowText("终止发送"); 
		m_bt_change_message.EnableWindow(FALSE); 
		m_bt_get_number.EnableWindow(FALSE); 
		m_bt_get_message.EnableWindow(FALSE); 
		m_ctr_message.EnableWindow(FALSE); 
		m_ctr_cnt.SetWindowText("0"); 
		m_ctr_prog.SetPos(0); 
		m_ctr_msg.DeleteAllItems(); 
	} 
	else 
	{ 
		issend = 0; 
		m_bt_send.SetWindowText("开始发送"); 
		m_bt_change_message.EnableWindow(TRUE); 
		m_bt_get_number.EnableWindow(TRUE); 
		m_bt_get_message.EnableWindow(TRUE); 
		m_ctr_message.EnableWindow(TRUE); 
	} 
} 
 
void CSmsDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
	CString str; 
	m_bt_send.GetWindowText(str); 
	if(str == "终止发送")  
	{ 
		AfxMessageBox("正在发送短信,请先终止发送!"); 
		return; 
	} 
	CloseComm(); 
	CDialog::OnOK(); 
} 
 
void CSmsDlg::OnClose()  
{ 
	// TODO: Add your message handler code here and/or call default 
	CString str; 
	m_bt_send.GetWindowText(str); 
	if(str == "终止发送")  
	{ 
		AfxMessageBox("正在发送短信,请先终止发送!"); 
		return; 
	} 
	CDialog::OnClose(); 
} 
 
void CSmsDlg::OnDestroy()  
{ 
	CString str; 
	m_bt_send.GetWindowText(str); 
	if(str == "终止发送")  
	{ 
		AfxMessageBox("正在发送短信,请先终止发送!"); 
		return; 
	} 
	CDialog::OnDestroy(); 
	 
	// TODO: Add your message handler code here 
	 
}