📄 unlockdeskwindow.cpp
字号:
// UnlockDeskWindow.cpp : implementation file
//
#include "stdafx.h"
#include "Server.h"
#include "UnlockDeskWindow.h"
#include "ServerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUnlockDeskWindow dialog
CUnlockDeskWindow::CUnlockDeskWindow(CWnd* pParent /*=NULL*/)
: CDialog(CUnlockDeskWindow::IDD, pParent)
{
//{{AFX_DATA_INIT(CUnlockDeskWindow)
m_strUnlockPassword = _T("");
//}}AFX_DATA_INIT
}
void CUnlockDeskWindow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUnlockDeskWindow)
DDX_Control(pDX, IDC_UNLOCK_PASSWORD, m_CtrlPassword);
DDX_Text(pDX, IDC_UNLOCK_PASSWORD, m_strUnlockPassword);
DDV_MaxChars(pDX, m_strUnlockPassword, 12);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUnlockDeskWindow, CDialog)
//{{AFX_MSG_MAP(CUnlockDeskWindow)
ON_WM_CTLCOLOR()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUnlockDeskWindow message handlers
void CUnlockDeskWindow::OnOK()
{
UpdateData(true);
CString strOldPass = AfxGetApp()->GetProfileString("PassWord","OldPassWord");
m_strUnlockPassword.TrimLeft();
m_strUnlockPassword.TrimRight();
int LockStatus = AfxGetApp()->GetProfileInt("LockWindow","Status",0);
if (LockStatus == 1 && strOldPass == "")
{
CDialog::OnOK();
AfxGetApp()->WriteProfileInt("LockWindow","Status",0);
int LockStatus = AfxGetApp()->GetProfileInt("LockWindow","Status",0);
CString str;
str.Format("%d",LockStatus);
return;
}
if (this->m_strUnlockPassword.GetLength() < 5)
{
AfxMessageBox("密码不正确,请重新输入!");
this->m_CtrlPassword.SetFocus();
return;
}
if ((strOldPass == this->m_strUnlockPassword) || (this->m_strUnlockPassword == this->strPassword && this->strPassword != "") )
{
CDialog::OnOK();
AfxGetApp()->WriteProfileInt("LockWindow","Status",0);
int LockStatus = AfxGetApp()->GetProfileInt("LockWindow","Status",0);
CString str;
str.Format("%d",LockStatus);
}
else
{
AfxMessageBox("密码不正确,请重新输入!");
this->m_CtrlPassword.SetWindowText("");
this->m_CtrlPassword.SetFocus();
return;
}
}
HBRUSH CUnlockDeskWindow::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,"解锁密码:",9) == 0)
{
pDC->SetTextColor(RGB(250,0,238));
}
}
return hbr;
}
BOOL CUnlockDeskWindow::OnInitDialog()
{
CDialog::OnInitDialog();
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED );
return TRUE;
}
void CUnlockDeskWindow::OnClose()
{
}
BOOL CUnlockDeskWindow::PreTranslateMessage(MSG* pMsg)
{
if (WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST)
{
if(pMsg->wParam==VK_ESCAPE)// || pMsg->wParam==VK_RETURN)
return true;
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -