📄 dlg_mima.cpp
字号:
// Dlg_Mima.cpp : 实现文件
//
#include "stdafx.h"
#include "文件加密.h"
#include "Dlg_Mima.h"
#include ".\dlg_mima.h"
// CDlg_Mima 对话框
extern CMyApp theApp;
IMPLEMENT_DYNAMIC(CDlg_Mima, CDialog)
CDlg_Mima::CDlg_Mima(CWnd* pParent /*=NULL*/)
: CDialog(CDlg_Mima::IDD, pParent)
, m_b_notusekey(true)
, m_s_oldkey(_T(""))
, m_s_newkey1(_T(""))
, m_s_newkey2(_T(""))
, m_b_haveoldkey(false)
{
CString settingfile,t;
settingfile.Format("%s\\setings.ini",theApp.m_path);
m_b_haveoldkey=::GetPrivateProfileInt("KEY","haveoldkey",0,settingfile);
m_b_notusekey=!m_b_haveoldkey;
}
CDlg_Mima::~CDlg_Mima()
{
}
void CDlg_Mima::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Check(pDX, IDC_NOTUSE, m_b_notusekey);
DDX_Text(pDX, IDC_OLDKEY, m_s_oldkey);
DDX_Text(pDX, IDC_NEWKEY1, m_s_newkey1);
DDX_Text(pDX, IDC_NEWKEY2, m_s_newkey2);
DDV_MaxChars(pDX, m_s_oldkey, 32);
DDV_MaxChars(pDX, m_s_newkey1, 32);
DDV_MaxChars(pDX, m_s_newkey2, 32);
}
BEGIN_MESSAGE_MAP(CDlg_Mima, CDialog)
ON_BN_CLICKED(IDC_NOTUSE, OnBnClickedNotuse)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
// CDlg_Mima 消息处理程序
void CDlg_Mima::OnBnClickedNotuse()
{
UpdateData(true);
if(m_b_notusekey)
{
if(m_b_haveoldkey)GetDlgItem(IDC_OLDKEY)->EnableWindow(true);
else GetDlgItem(IDC_OLDKEY)->EnableWindow(false);
GetDlgItem(IDC_NEWKEY1)->EnableWindow(false);
GetDlgItem(IDC_NEWKEY2)->EnableWindow(false);
}
else
{
if(m_b_haveoldkey)GetDlgItem(IDC_OLDKEY)->EnableWindow(true);
else GetDlgItem(IDC_OLDKEY)->EnableWindow(false);
GetDlgItem(IDC_NEWKEY1)->EnableWindow(true);
GetDlgItem(IDC_NEWKEY2)->EnableWindow(true);
}
}
BOOL CDlg_Mima::OnInitDialog()
{
CDialog::OnInitDialog();
OnBnClickedNotuse();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CDlg_Mima::OnBnClickedOk()
{
theApp;
CString settingfile,t;
if(!UpdateData())return;
settingfile.Format("%s\\setings.ini",theApp.m_path);
if(m_b_haveoldkey)//如果有旧密码
{
::GetPrivateProfileString("KEY","key","",t.GetBuffer(40),40,settingfile);
if(strcmp(m_s_oldkey,t)!=0)
{
AfxMessageBox("请输入正确的旧密码!");
return;
}
}
if(!m_b_notusekey)//如果使用密码
{
if(strcmp(m_s_newkey1,m_s_newkey2)!=0)
{
AfxMessageBox("两次输入的密码不相同!");
return;
}
::WritePrivateProfileString("KEY","haveoldkey","1",settingfile);
::WritePrivateProfileString("KEY","key",m_s_newkey1,settingfile);
}
else
{
::WritePrivateProfileString("KEY","haveoldkey","0",settingfile);
}
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -