⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlg_password.cpp

📁 IdentityCardQuery是一个基于ado身份证查询系统,包括多表操作,查询,添加,删除等.
💻 CPP
字号:
// Dlg_PassWord.cpp : implementation file
//

#include "stdafx.h"
#include "IdentityCardQuery.h"
#include "Dlg_PassWord.h"
#include "Registry.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlg_PassWord dialog


CDlg_PassWord::CDlg_PassWord(CWnd* pParent /*=NULL*/)
	: CDialog(CDlg_PassWord::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlg_PassWord)
	m_strPassWord = _T("");
	m_bRememberPassWord = FALSE;
	//}}AFX_DATA_INIT
}


void CDlg_PassWord::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlg_PassWord)
	DDX_Control(pDX, IDCANCEL, m_BT_Cancel);
	DDX_Control(pDX, IDOK, m_BT_OK);
	DDX_Control(pDX, IDC_COMBO_type, m_ComboType);
	DDX_Text(pDX, IDC_EDIT_PASSWORD, m_strPassWord);
	DDX_Check(pDX, IDC_CHECK_REMEMBER, m_bRememberPassWord);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlg_PassWord, CDialog)
	//{{AFX_MSG_MAP(CDlg_PassWord)
	ON_CBN_SELCHANGE(IDC_COMBO_type, OnSelchangeCOMBOtype)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlg_PassWord message handlers

void CDlg_PassWord::OnOK() 
{
	UpdateData();
    if (m_bAdministrator)
	{
		if (m_strPassWord.IsEmpty())
		{
			MessageBox(_T("密码不能为空"),_T("提示"));
			return;
		}
		
		if (m_strPassWord != _T("zhangxiqin"))
		{
			MessageBox(_T("密码不正确"),_T("提示"));
			return;
		}

		CRegistry Registry;
		CString strPath = _T("SOFTWARE\\IDENTITYCARD\\");
		if (!Registry.VerifyKey(strPath))
			Registry.CreateKey(strPath);
		if (m_bRememberPassWord)
		{			
			Registry.Write("PASSWORD",m_strPassWord);
			Registry.Write("REMEMBER",m_bRememberPassWord);
			Registry.Close();
		}
		else
		{
			Registry.DeleteKey(strPath);
		}
	}
		
	CDialog::OnOK();
}

BOOL CDlg_PassWord::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

	m_ComboType.AddString(_T("管理员"));
	m_ComboType.AddString(_T("游客"));
	m_ComboType.SetCurSel(0);

	GetDlgItem(IDC_EDIT_PASSWORD)->EnableWindow(true);
	m_bAdministrator = true;

	//检查注册表
	CRegistry Registry;
	CString strPath = _T("SOFTWARE\\IDENTITYCARD\\");
	
	if (Registry.VerifyKey(strPath))
	{
		Registry.Read("REMEMBER",m_bRememberPassWord);
		if (m_bRememberPassWord)
			Registry.Read("PASSWORD",m_strPassWord);
		Registry.Close();

		UpdateData(FALSE);
	}

//	HICON icon = LoadIcon(AfxGetApp()->m_hInstance,(LPCSTR)IDI_PASSWORD);
	HICON icon = LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_PASSWORD));
	this->SetIcon(icon,TRUE);

	m_BT_Cancel.SetIcon(IDI_ICON_DEL);
	m_BT_OK.SetIcon(IDI_ICON_EXIT);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlg_PassWord::OnSelchangeCOMBOtype() 
{
	 if (m_ComboType.GetCurSel() == 0)
	 {
		 m_bAdministrator  = true;
		 GetDlgItem(IDC_EDIT_PASSWORD)->EnableWindow(TRUE);
		 GetDlgItem(IDC_CHECK_REMEMBER)->EnableWindow(TRUE);
	 }
	 else
	 {
		 m_bAdministrator  = false;
		 GetDlgItem(IDC_EDIT_PASSWORD)->EnableWindow(FALSE);
		 GetDlgItem(IDC_CHECK_REMEMBER)->EnableWindow(FALSE);
	 }
	
}

⌨️ 快捷键说明

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