You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.8 KiB
C++

// DlgAuthorityMgr->cpp : 实现文件
//
#include "stdafx.h"
#include "LaiPuLaser.h"
#include "DlgAuthorityLogin.h"
#include "afxdialogex.h"
#include "MsgBox.h"
#include "AuthorityMgr.h"
#include "LogMgr.h"
#include "GlobalFunction.h"
IMPLEMENT_DYNAMIC(CDlgAuthorityLogin, CDialogEx)
CDlgAuthorityLogin::CDlgAuthorityLogin(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgAuthorityLogin::IDD, pParent)
{
}
CDlgAuthorityLogin::~CDlgAuthorityLogin()
{
}
void CDlgAuthorityLogin::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_NAME, m_Name);
DDX_Text(pDX, IDC_PASSWORD, m_PassWord);
DDX_Control(pDX, NEW_LOGIN_BTN, m_LoginBtn);
}
BEGIN_MESSAGE_MAP(CDlgAuthorityLogin, CDialogEx)
ON_WM_PAINT()
ON_BN_CLICKED(NEW_LOGIN_BTN, &CDlgAuthorityLogin::OnBnClickedLogin)
ON_BN_CLICKED(CHILD_SHOW_WINDOW_MIN_BTN, &CDlgAuthorityLogin::OnBnClickedShowWindowMinBtn)
END_MESSAGE_MAP()
//截获一部分键盘输入
BOOL CDlgAuthorityLogin::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);
}
void CDlgAuthorityLogin::OnCancel()
{
return;
//CDialogEx::OnCancel();
}
// CDlgAuthorityCreatAccount 消息处理程序
BOOL CDlgAuthorityLogin::OnInitDialog()
{
CDialogEx::OnInitDialog();
CRect cr;
GetClientRect(&cr);
ClientToScreen(&cr);
//设置对话框的位置
MoveWindow(2 ,0,cr.Width()+20,cr.Height()+20);
m_LoginBtn.SetUpColor(RGB_GREEN);
gAuthorityMgr->Lock();
gAuthorityMgr->SetbLoginDlgOpen(true);
UpdateData(FALSE);
return TRUE;
}
void CDlgAuthorityLogin::OnPaint()
{
{
//
// 给窗体添加背景
//
CPaintDC dc(this);
CRect rc;
GetClientRect(&rc);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BTN_IMG123);
BITMAP bitmap;
bmpBackground.GetBitmap(&bitmap);
CBitmap* pOldBitmap = dcMem.SelectObject(&bmpBackground);
dc.StretchBlt(0,0,bitmap.bmWidth,bitmap.bmHeight, &dcMem,0,0,bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
dcMem.SelectObject(pOldBitmap);
VERIFY(dcMem.DeleteDC());
}
}
//登录
void CDlgAuthorityLogin::OnBnClickedLogin()
{
if(!UpdateData(TRUE))
return;
if(gAuthorityMgr->Login(m_Name,m_PassWord))
{
gAuthorityMgr->SetbLoginDlgOpen(false);
OnOK();
}
}
void CDlgAuthorityLogin::OnBnClickedShowWindowMinBtn()
{
gLogMgr->WriteDebugLog("Func---->OnBnClickedShowWindowMinBtn");
GetFrame()->ShowWindowMin();
}