// DlgAuthorityMgr->cpp : 实现文件 // #include "stdafx.h" #include "LaiPuLaser.h" #include "DlgAuthorityMgr.h" #include "afxdialogex.h" #include "MsgBox.h" #include "AuthorityMgr.h" // CDlgAuthorityMgr 对话框 IMPLEMENT_DYNAMIC(CDlgAuthorityMgr, CDialogEx) CDlgAuthorityMgr::CDlgAuthorityMgr(CWnd* pParent /*=NULL*/) : CDialogEx(CDlgAuthorityMgr::IDD, pParent) , m_CurUser(_T("")) { } CDlgAuthorityMgr::~CDlgAuthorityMgr() { } void CDlgAuthorityMgr::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Text(pDX, IDC_AUTHORITY, m_CurAuthority); DDX_Text(pDX, IDC_NAME, m_Name); DDX_Text(pDX, IDC_PASSWORD, m_PassWord); DDX_Text(pDX, IDC_CUR_USER, m_CurUser); DDX_Control(pDX, IDC_LOGIN, m_LoginBtn); DDX_Control(pDX, IDC_LOCK_USER, m_LockBtn); } BEGIN_MESSAGE_MAP(CDlgAuthorityMgr, CDialogEx) ON_BN_CLICKED(IDC_LOGIN, &CDlgAuthorityMgr::OnBnClickedLogin) ON_BN_CLICKED(IDC_LOCK_USER, &CDlgAuthorityMgr::OnBnClickedLock) END_MESSAGE_MAP() //截获一部分键盘输入 BOOL CDlgAuthorityMgr::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN) { char c = pMsg->wParam; if(c==VK_RETURN || c==VK_ESCAPE) { return TRUE; } } return CDialogEx::PreTranslateMessage(pMsg); } // CDlgCreatAccount 消息处理程序 BOOL CDlgAuthorityMgr::OnInitDialog() { CDialogEx::OnInitDialog(); m_LoginBtn.SetUpColor(RGB_GREEN); //刷新当前权限 RefreashAuthority(); UpdateData(FALSE); return TRUE; } //登录 void CDlgAuthorityMgr::OnBnClickedLogin() { UpdateData(TRUE); if(gAuthorityMgr->Login(m_Name,m_PassWord)) { //刷新当前权限 RefreashAuthority(); OnOK(); } } //刷新当前权限 void CDlgAuthorityMgr::RefreashAuthority() { m_CurAuthority = gAuthorityMgr->GetAccountName(gAuthorityMgr->GetCurAuthority()); m_CurUser = gAuthorityMgr->GetCurUserName(); UpdateData(FALSE); } void CDlgAuthorityMgr::OnBnClickedLock() { gAuthorityMgr->Lock(); CMsgBox MsgBox; MsgBox.Show("用户锁定Lock"); CDialogEx::OnCancel(); }