// LonInDlg.cpp : implementation file // #include "stdafx.h" #include "HRM.h" #include "LonInDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CLonInDlg dialog CLonInDlg::CLonInDlg(CWnd* pParent /*=NULL*/) : CDialog(CLonInDlg::IDD, pParent) { //{{AFX_DATA_INIT(CLonInDlg) m_WorkID = _T(""); m_PassWord = _T(""); //}}AFX_DATA_INIT m_times = 0; } void CLonInDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CLonInDlg) DDX_Control(pDX, IDCANCEL, m_Cancel); DDX_Control(pDX, IDOK, m_OK); DDX_Text(pDX, IDC_EDIT5, m_WorkID); DDX_Text(pDX, IDC_EDIT6, m_PassWord); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CLonInDlg, CDialog) //{{AFX_MSG_MAP(CLonInDlg) // NOTE: the ClassWizard will add message map macros here //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLonInDlg message handlers BOOL CLonInDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message == WM_LBUTTONDOWN ) { CRect rect,rc; m_OK.GetWindowRect(&rect); m_Cancel.GetWindowRect(&rc); CPoint point; GetCursorPos(&point); if(rect.PtInRect(point)) { UpdateData(TRUE); if(m_WorkID.IsEmpty() || m_PassWord.IsEmpty()) { MessageBox("用户名或密码不能为空"); return FALSE; } m_times++; if(m_WorkID =="1" && m_PassWord == "2") { CDialog::OnOK(); } else { if(m_times == 3) { MessageBox("密码不正确已达3次,系统将自动退出!"); CDialog::OnCancel(); this->GetParent()->PostMessage(WM_QUIT); } else { CString str ; str.Format("用户名或密码不正确,您还可以输入%d次!",3 - m_times); MessageBox(str); m_WorkID = ""; m_PassWord = ""; UpdateData(FALSE); } } } if(rc.PtInRect(point)) { CDialog::OnCancel(); this->GetParent()->PostMessage(WM_QUIT); } } return CDialog::PreTranslateMessage(pMsg); }