123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- // EmailInfo.cpp : implementation file
- //
- #include "stdafx.h"
- #include "StoneU_HC_OCX.h"
- #include "EmailInfo.h"
- #include ".\emailinfo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEmailInfo dialog
- BOOL EmailCh_is_Legal(BOOL front,TCHAR ch)
- {
- if(ch<='z'&&ch>='a' || ch<='Z'&&ch>='A' || ch<='9'&&ch>='0')
- return TRUE;
- if(front && (ch == '-' || ch =='_'))
- return TRUE;
- if(!front && ch =='.')
- return TRUE;
- return FALSE;
- }
- BOOL CheckEmailAddress(CString email)
- {
- int pos = email.Find('@');
- if(pos == -1 || pos == 0 || pos == (email.GetLength()-1))
- return FALSE;
- CString tmp = email.Left(pos);
- int i;
- for(i=0;i<pos;i++)
- if(!EmailCh_is_Legal(TRUE,tmp.GetAt(i)))
- return FALSE;
- tmp.Empty();
- tmp = email.Right(email.GetLength()-1-pos);
- pos = tmp.Find('.');
- if(pos == -1 || pos == 0 || pos == (tmp.GetLength()-1))
- return FALSE;
- for(i=0;i<tmp.GetLength();i++)
- if(!EmailCh_is_Legal(FALSE,tmp.GetAt(i)))
- return FALSE;
- return TRUE;
- }
- CEmailInfo::CEmailInfo(CWnd* pParent /*=NULL*/)
- : CDialog(CEmailInfo::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CEmailInfo)
- m_EmailName = _T("");
- m_EmailAddress = _T("");
- //}}AFX_DATA_INIT
- }
- void CEmailInfo::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CEmailInfo)
- DDX_Text(pDX, IDC_EMAILNAME, m_EmailName);
- DDX_Text(pDX, IDC_EMAILADDRESS, m_EmailAddress);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CEmailInfo, CDialog)
- //{{AFX_MSG_MAP(CEmailInfo)
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEmailInfo message handlers
- void CEmailInfo::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(TRUE);
- if(m_EmailName.IsEmpty())
- {
- MessageBox("姓名不能为空!", "温馨提示", MB_ICONINFORMATION);
- return;
- }
- if(!CheckEmailAddress(m_EmailAddress))
- {
- MessageBox("Email地址非法!请确认后重输...!", "温馨提示", MB_ICONINFORMATION);
- return;
- }
- CDialog::OnOK();
- }
- void CEmailInfo::OnCancel()
- {
- // TODO: Add extra cleanup here
-
- CDialog::OnCancel();
- }
- void CEmailInfo::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- OnOK();
- }
|