📄 newuser.cpp
字号:
// Newuser.cpp : implementation file
//
#include "stdafx.h"
#include "MoinorCentre.h"
#include "Newuser.h"
#include "UserDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNewuser dialog
CNewuser::CNewuser(CWnd* pParent /*=NULL*/)
: CDialog(CNewuser::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewuser)
m_name = _T("");
m_key = _T("");
m_keyrepeat = _T("");
//}}AFX_DATA_INIT
}
void CNewuser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewuser)
DDX_Text(pDX, IDC_EDIT1, m_name);
DDX_Text(pDX, IDC_EDIT2, m_key);
DDX_Text(pDX, IDC_EDIT3, m_keyrepeat);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewuser, CDialog)
//{{AFX_MSG_MAP(CNewuser)
ON_WM_CLOSE()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewuser message handlers
void CNewuser::OnOK()
{ UpdateData();
if(m_name.IsEmpty())
AfxMessageBox("请输入新管理员帐号名");
else
{
if(m_key!=m_keyrepeat)
AfxMessageBox("两次输入密码不同请重新输入");
else
{
((CUserDialog*)GetParent())->m_user.AddNew();
((CUserDialog*)GetParent())->m_user.m_username=m_name;
((CUserDialog*)GetParent())->m_user.m_userkey=m_key;
((CUserDialog*)GetParent())->m_userlist.AddString(m_name);
((CUserDialog*)GetParent())->m_user.Update();
((CUserDialog*)GetParent())->usernum++;
AfxMessageBox("管理员账户添加成功");
this->GetParent()->ShowWindow(SW_SHOW);
CDialog::OnOK();
}
}
}
void CNewuser::OnClose()
{m_brush.DeleteObject();
this->GetParent()->ShowWindow(SW_SHOW);
CDialog::OnClose();
}
void CNewuser::OnCancel()
{
this->GetParent()->ShowWindow(SW_SHOW);
CDialog::OnCancel();
}
HBRUSH CNewuser::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_DLG)
{
return m_brush;
}
if(nCtlColor == CTLCOLOR_STATIC)
{ pDC->SetBkMode(0);
pDC->SetTextColor(RGB(255,100,70));
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
return hbr;
}
// TODO: Return a different brush if the default is not desired
// TODO: Return a different brush if the default is not desired
return hbr;
}
BOOL CNewuser::OnInitDialog()
{
CDialog::OnInitDialog();
beijing.Load(".//res//dd.bmp");
CRect ff;
GetWindowRect(ff);
beijing.ChangeImageSize(ff.Width(),ff.Height());
m_brush.CreateDIBPatternBrush(beijing.m_hDib,DIB_PAL_COLORS);
m_ok.SubclassDlgItem(IDOK,this);
m_ok.SetIcon(IDI_OK);
m_ok.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_ok.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_ok.DrawTransparent(TRUE);
m_cancle.SubclassDlgItem(IDCANCEL,this);
m_cancle.SetIcon(IDI_CANCLE);
m_cancle.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
m_cancle.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
m_cancle.DrawTransparent(TRUE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -