📄 setpwddlg.cpp
字号:
// SetPWDDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SGAdrLstMS.h"
#include "SetPWDDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetPWDDlg dialog
CSetPWDDlg::CSetPWDDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSetPWDDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetPWDDlg)
m_password = _T("");
m_repass = _T("");
m_setpass = FALSE;
//}}AFX_DATA_INIT
}
void CSetPWDDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetPWDDlg)
DDX_Text(pDX, IDC_PASSWORD, m_password);
DDX_Text(pDX, IDC_REPASS, m_repass);
DDX_Check(pDX, IDC_SETPASS, m_setpass);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetPWDDlg, CDialog)
//{{AFX_MSG_MAP(CSetPWDDlg)
ON_BN_CLICKED(IDC_SETPASS, OnSetpass)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetPWDDlg message handlers
BOOL CSetPWDDlg::OnInitDialog()
{
CDialog::OnInitDialog();
db.Open();
this->UpdateData(true);
this->m_setpass = db.m_startup;
this->UpdateData(false);
if (db.m_pwd != "")
{
this->GetDlgItem(IDC_SSET)->SetWindowText("修改密码");
this->GetDlgItem(IDOK)->SetWindowText("修改");
}
if (this->m_setpass == false)
{
this->GetDlgItem(IDC_PASSWORD)->EnableWindow(false);
this->GetDlgItem(IDC_REPASS)->EnableWindow(false);
}
db.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSetPWDDlg::OnSetpass()
{
db.Open();
db.MoveFirst();
this->UpdateData(true);
this->GetDlgItem(IDC_PASSWORD)->EnableWindow(this->m_setpass);
this->GetDlgItem(IDC_PASSWORD)->SetFocus();
this->GetDlgItem(IDC_REPASS)->EnableWindow(this->m_setpass);
db.Edit();
db.m_startup = this->m_setpass;
db.Update();
db.Close();
}
void CSetPWDDlg::OnOK()
{
this->UpdateData(true);
if (this->m_setpass == TRUE)
{
if (this->m_password != this->m_repass)
{
AfxMessageBox("确认密码不一致",MB_ICONEXCLAMATION);
this->GetDlgItem(IDC_REPASS)->SetFocus();
return;
}
db.Open();
db.MoveFirst();
db.Edit();
this->GenCode();
db.Update();
db.Close();
MessageBox("操作成功","系统安全",MB_ICONINFORMATION);
}
CDialog::OnOK();
}
void CSetPWDDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
this->GetDlgItem(IDC_PASSWORD)->SetFocus();
}
void CSetPWDDlg::OnButton1()
{
CDialog::OnOK();
}
void CSetPWDDlg::GenCode()
{
db.m_pwd = this->m_password;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -