| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- // DlgLogin.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "OGCAssistTool.h"
- #include "DlgLogin.h"
- #include "MD5.h"
- // CDlgLogin 对话框
- IMPLEMENT_DYNAMIC(CDlgLogin, CDialogEx)
- CDlgLogin::CDlgLogin(CWnd* pParent /*=NULL*/)
- : CDialogEx(CDlgLogin::IDD, pParent)
- {
- }
- CDlgLogin::~CDlgLogin()
- {
- }
- void CDlgLogin::DoDataExchange(CDataExchange* pDX)
- {
- CDialogEx::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CDlgLogin, CDialogEx)
- ON_WM_CTLCOLOR()
- ON_BN_CLICKED(IDOK, &CDlgLogin::OnBnClickedOk)
- ON_BN_CLICKED(IDCANCEL, &CDlgLogin::OnBnClickedCancel)
- END_MESSAGE_MAP()
- // CDlgLogin 消息处理程序
- BOOL CDlgLogin::OnInitDialog()
- {
- CDialogEx::OnInitDialog();
- // TODO: 在此添加额外的初始化
- CFont font;
- VERIFY(font.CreateFont(
- 19, // nHeight
- 0, // nWidth
- 0, // nEscapement
- 0, // nOrientation
- FW_NORMAL, // nWeight
- FALSE, // bItalic
- FALSE, // bUnderline
- 0, // cStrikeOut
- ANSI_CHARSET, // nCharSet
- OUT_DEFAULT_PRECIS, // nOutPrecision
- CLIP_DEFAULT_PRECIS, // nClipPrecision
- DEFAULT_QUALITY, // nQuality
- DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
- _T("Arial")));
- SetFont(&font);
- //SetBackgroundColor(RGB(125,0,25));
- SetBackgroundImage(IDB_LOGO);
- if ( _tcslen(GLOBAL::g_config.szLine) )
- SetDlgItemText(EDIT_LINE, GLOBAL::g_config.szLine);
- if ( _tcslen(GLOBAL::g_config.szAccount) )
- SetDlgItemText(EDIT_ACCOUNT, GLOBAL::g_config.szAccount);
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- HBRUSH CDlgLogin::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: 在此更改 DC 的任何属性
- switch ( pWnd->GetDlgCtrlID() )
- {
- case CHECK_OFFLINE:
- {
- #if 1 // 透明控件处理;
- pDC->SetBkMode(TRANSPARENT);
- CRect rc;
- pWnd->GetWindowRect(&rc);
- ScreenToClient(&rc);
- CDC* dc = GetDC();
- pDC->BitBlt(0,0,rc.Width(),rc.Height(),dc,rc.left,rc.top,SRCCOPY); //把父窗口背景图片先画到按钮上
- ReleaseDC(dc);
- hbr = (HBRUSH) ::GetStockObject(NULL_BRUSH);
- #endif
- }
- break;
- default:
- break;
- }
- // TODO: 如果默认的不是所需画笔,则返回另一个画笔
- return hbr;
- }
- void CDlgLogin::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- CString strAccount, strPassword, strLine;
- GetDlgItemText(EDIT_LINE, strLine);
- GetDlgItemText(EDIT_ACCOUNT, strAccount);
- GetDlgItemText(EDIT_PASSWORD, strPassword);
- #ifdef _DEBUG
- GLOBAL::g_config.nOffline = ((CButton*)GetDlgItem(CHECK_OFFLINE))->GetCheck();
- _stprintf_s(GLOBAL::g_config.szLine, _T("%s"), strLine.GetString());
- return CDialogEx::OnOK();
- #endif
- if ( strAccount.IsEmpty() )
- {
- MessageBox(_T("请输入账号"), _T("提示"), MB_OK);
- return;
- }
- if ( strPassword.IsEmpty() )
- {
- MessageBox(_T("请输入密码"), _T("提示"), MB_OK);
- return;
- }
- if ( strLine.IsEmpty() )
- {
- MessageBox(_T("请输入线体"), _T("提示"), MB_OK);
- return;
- }
- GLOBAL::g_config.nOffline = ((CButton*)GetDlgItem(CHECK_OFFLINE))->GetCheck();
- _stprintf_s(GLOBAL::g_config.szLine, _T("%s"), strLine.GetString());
- #pragma region 账号密码验证
- // 获取账号密码;
- // 默认账号密码:OGCAssist、OGC+当前PC日期年月日;
- if ( _tcslen(GLOBAL::g_config.szAccount) == 0 )
- {
- if ( strAccount != _T("Assist") )
- {
- MessageBox(_T("账号错误"), _T("提示"), MB_OK);
- return;
- }
- CString strDynamicPassword;
- strDynamicPassword.Format(_T("OGC%s"), CTime::GetCurrentTime().Format(_T("%y%m%d")));
- if ( strPassword != strDynamicPassword )
- {
- MessageBox(_T("密码错误"), _T("提示"), MB_OK);
- return;
- }
- }
- else
- {
- CMD5 md5((BYTE*)strPassword.GetString(), strPassword.GetLength()*sizeof(TCHAR));
- if ( _tcscmp(GLOBAL::g_config.szAccount, strAccount.GetString()) != 0 )
- {
- MessageBox(_T("账号错误"), _T("提示"), MB_OK);
- return;
- }
- if ( _tcscmp(GLOBAL::g_config.szPassword, md5.GetMD5Digest()) != 0 )
- {
- MessageBox(_T("账号错误"), _T("提示"), MB_OK);
- return;
- }
- }
- #pragma endregion
- CDialogEx::OnOK();
- }
- void CDlgLogin::OnBnClickedCancel()
- {
- // TODO: 在此添加控件通知处理程序代码
- CDialogEx::OnCancel();
- }
|