📄 lockdeskwindow.cpp
字号:
// LockDeskWindow.cpp : implementation file
//
#include "stdafx.h"
#include "Server.h"
#include "LockDeskWindow.h"
#include "ServerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLockDeskWindow dialog
CLockDeskWindow::CLockDeskWindow(CWnd* pParent /*=NULL*/)
: CDialog(CLockDeskWindow::IDD, pParent)
{
//{{AFX_DATA_INIT(CLockDeskWindow)
m_strPassword = _T("");
m_strConfirmPass = _T("");
//}}AFX_DATA_INIT
}
void CLockDeskWindow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLockDeskWindow)
DDX_Control(pDX, IDC_CONFIRM_PASSWORD, m_CtrlConfirmPass);
DDX_Control(pDX, IDC_PASSWORD, m_CtrlPassword);
DDX_Text(pDX, IDC_PASSWORD, m_strPassword);
DDV_MaxChars(pDX, m_strPassword, 12);
DDX_Text(pDX, IDC_CONFIRM_PASSWORD, m_strConfirmPass);
DDV_MaxChars(pDX, m_strConfirmPass, 12);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLockDeskWindow, CDialog)
//{{AFX_MSG_MAP(CLockDeskWindow)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLockDeskWindow message handlers
void CLockDeskWindow::OnOK()
{
UpdateData(true);
this->m_strPassword.TrimLeft();
this->m_strPassword.TrimRight();
if (this->m_strPassword == "")
{
AfxMessageBox("密码不能为空!");
GetDlgItem(IDC_PASSWORD)->SetFocus();
return;
}
if(this->m_strPassword == this->m_strConfirmPass && this->m_strPassword.GetLength() >= 5)
{
CDialog::OnOK();
CUnlockDeskWindow dlg;
dlg.strPassword = this->m_strPassword;
dlg.DoModal();
AfxGetApp()->WriteProfileInt("LockWindow","Status",1);
}
else
{
this->m_CtrlPassword.SetWindowText("");
this->m_CtrlConfirmPass.SetWindowText("");
this->m_CtrlPassword.SetFocus();
AfxMessageBox("密码不匹配,请重新输入!");
}
}
HBRUSH CLockDeskWindow::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_STATIC)
{
CString ss;
pWnd->GetWindowText(ss);
if(memcmp(ss,"密码框",6) != 0)
{
pDC->SetTextColor(RGB(250,0,238));
}
else
pDC->SetTextColor(RGB(0,0,238));
}
return hbr;
}
BOOL CLockDeskWindow::OnInitDialog()
{
CDialog::OnInitDialog();
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED );
return TRUE;
}
BOOL CLockDeskWindow::PreTranslateMessage(MSG* pMsg)
{
if (WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST)
{
if(pMsg->wParam==VK_ESCAPE)
return true;
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -