www.pudn.com > agsm2-1.2_src.zip > PBDialog.cpp


// PBDialog.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "agsm2.h" 
#include "PBDialog.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CPBDialog dialog 
 
 
CPBDialog::CPBDialog(CWnd* pParent /*=NULL*/) 
	: CDialog(CPBDialog::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CPBDialog) 
	m_editName = _T(""); 
	m_editPhone = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void CPBDialog::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CPBDialog) 
	DDX_Text(pDX, IDC_EDIT_NAME, m_editName); 
	DDV_MaxChars(pDX, m_editName, 7); 
	DDX_Text(pDX, IDC_EDIT_PHONE, m_editPhone); 
	DDV_MaxChars(pDX, m_editPhone, 40); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CPBDialog, CDialog) 
	//{{AFX_MSG_MAP(CPBDialog) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CPBDialog message handlers 
 
void CPBDialog::OnOK()  
{ 
	// TODO: Add extra validation here 
	UpdateData(); 
	TRACE("name=%s\n",m_editName); 
	TRACE("phone=%s\n",m_editPhone); 
	char *buf = m_editPhone.GetBuffer(m_editPhone.GetLength()); 
	char buf1[512]; 
	int ret = sscanf(buf,"%[0-9*#]",buf1); 
	if(ret) 
		ret = (strlen(buf) == strlen(buf1)); 
	int ret1 = sscanf(buf,"+%[0-9*#p]",buf1); 
	if(ret1) 
		ret1 = (strlen(buf) == strlen(buf1)+1); 
 
	if(ret || ret1) 
		CDialog::OnOK(); 
	else 
		AfxMessageBox(IDS_STRING119); 
}