enterpaswd.cpp

来自「一个模仿ATM提款机的MFC程序」· C++ 代码 · 共 102 行

CPP
102
字号
// EnterPaswd.cpp : implementation file
//

#include "stdafx.h"
#include "ATM.h"
#include "EnterPaswd.h"
#include "NewAccount.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEnterPaswd dialog

CString CEnterPaswd::m_password="";

CEnterPaswd::CEnterPaswd(CWnd* pParent /*=NULL*/)
	: CDialog(CEnterPaswd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CEnterPaswd)
//	m_password = _T("");
	//}}AFX_DATA_INIT
}


void CEnterPaswd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEnterPaswd)
	DDX_Control(pDX, IDC_PASSWORD, m_passedit);
	DDX_Text(pDX, IDC_PASSWORD, m_password);
	//}}AFX_DATA_MAP
	SetTimer(0,15000,NULL);
}


BEGIN_MESSAGE_MAP(CEnterPaswd, CDialog)
	//{{AFX_MSG_MAP(CEnterPaswd)
	ON_BN_CLICKED(IDC_CORRECT, OnCorrect)
	ON_BN_CLICKED(IDC_EXIT, OnExit)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEnterPaswd message handlers

void CEnterPaswd::OnOK() 
{
//	NewAccount dlg;
//	dlg.DoModal();
	// TODO: Add extra validation here
	//KillTimer(0);
	CDialog::OnOK();
}

void CEnterPaswd::OnCorrect() 
{
	// TODO: Add your control notification handler code here
	m_passedit.SetWindowText("");
	
}

void CEnterPaswd::OnExit() 
{
	// TODO: Add your control notification handler code here
	CEnd endlg;
	endlg.DoModal();
	exit(0);
	
}


BOOL CEnterPaswd::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	switch(pMsg->message)
	{
	case WM_KEYUP:
		SetTimer(0,15000,NULL);
		if(m_passedit.GetWindowTextLength()==6)CDialog::OnOK();
		break;
	case WM_KEYDOWN:KillTimer(0);break;
	}
	
	return CDialog::PreTranslateMessage(pMsg);
}

void CEnterPaswd::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	Beep(1000,500);
	KillTimer(0);
	CAlarm alarmdlg;
	alarmdlg.DoModal();
	
	CDialog::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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