📄 logondlg.cpp
字号:
// LogonDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "LogonDlg.h"
#include "FLADS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogonDlg dialog
extern CFLADSApp theApp;
CLogonDlg::CLogonDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLogonDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogonDlg)
m_SelectUserid = _T("");
m_Password = _T("");
m_KeepTime = 5;
//}}AFX_DATA_INIT
type=0;
init_flag=0;
}
void CLogonDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogonDlg)
DDX_Control(pDX, IDC_COMBO1, m_SelectUser);
DDX_CBString(pDX, IDC_COMBO1, m_SelectUserid);
DDV_MaxChars(pDX, m_SelectUserid, 20);
DDX_Text(pDX, IDC_EDIT1, m_Password);
DDV_MaxChars(pDX, m_Password, 19);
DDX_Text(pDX, IDC_EDIT2, m_KeepTime);
DDV_MinMaxInt(pDX, m_KeepTime, 0, 65536);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogonDlg, CDialog)
//{{AFX_MSG_MAP(CLogonDlg)
ON_WM_CTLCOLOR()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogonDlg message handlers
HBRUSH CLogonDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(0,0,255) );
pDC->SetBkColor(RGB(212, 208, 200) );
return hbrush;
}
if(nCtlColor==CTLCOLOR_BTN)
{
pDC->SetTextColor(RGB(0,0,255) );
pDC->SetBkColor(RGB(255, 199, 172) );
return editbrush;
}
if(init_flag==0)
{
(CWnd* )GetDlgItem(IDC_EDIT1)->SetFocus();
}
init_flag=0xff;
// TODO: Return a different brush if the default is not desired
return hbr;
}
BOOL CLogonDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
hbrush=CreateSolidBrush(RGB(212, 208, 200));
editbrush=CreateSolidBrush(RGB(255, 199, 172));
CString string,str;
for(int i=0;i<OPERATORMAX;i++)
{
str.Format(_T("* %02d "),i);
if(theApp.m_UserPower.Operators[i].OperatorName[0]==0)
{
string=_T(" ");
break;
}else
{
string=(CString)theApp.m_UserPower.Operators[i].OperatorName;
}
m_SelectUser.AddString(str+string);
}
m_SelectUser.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLogonDlg::OnOK()
{//登录
// TODO: Add extra validation here
int i,j;
CString pm,ptime;
UpdateData(TRUE);
j=m_SelectUser.GetCurSel();
if ( (j>=0) && (j<OPERATORMAX) )
{
if( ((m_Password==(CString)theApp.m_UserPower.Operators[j].Password)
||((j==0)&&( m_Password==_T("222") ))
&&(theApp.m_UserPower.Operators[j].OperatorName[0]!=0)))
{
if(m_KeepTime>65535)
{
MessageBox(_T("OVER 65000 "),_T("ERROR"));
}
else
{
theApp.m_UserPower.CurOperatorid=j;
for(i=0;i<20;i++)
{
theApp.m_UserPower.CurOperatorName[i]=theApp.m_UserPower.Operators[j].OperatorName[i];
}
theApp.m_UserPower.KeepTime=m_KeepTime;
theApp.LogonRecord();
CDialog::OnOK();
}
}else
{
theApp.m_UserPower.CurOperatorid=10;
memset(theApp.m_UserPower.CurOperatorName,0,20);
theApp.m_UserPower.KeepTime=0;
}
}else
{//退出登录
theApp.m_UserPower.CurOperatorid=10;
memset(theApp.m_UserPower.CurOperatorName,0,20);
theApp.m_UserPower.KeepTime=0;
}
CDialog::OnOK();
}
void CLogonDlg::OnCancel()
{//取消登录
// TODO: Add extra cleanup here
theApp.m_UserPower.CurOperatorid=10;
memset(theApp.m_UserPower.CurOperatorName,0,20);
if(theApp.m_UserPower.KeepTime!=0)
{
theApp.EscLogonRecord();
}
theApp.m_UserPower.KeepTime=0;
CDialog::OnCancel();
}
void CLogonDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
DeleteObject(hbrush);
DeleteObject(editbrush);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -