📄 logindlg.cpp
字号:
// LoginDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MyQQClient.h"
#include "LoginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog
CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLoginDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLoginDlg)
m_iID = 10000001;
m_iPSW = 123456;
//}}AFX_DATA_INIT
nResponse = 0;
}
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDlg)
DDX_Control(pDX, IDC_PSW, m_editPSW);
DDX_Control(pDX, IDC_ID, m_editID);
DDX_Control(pDX, IDC_MSG_PSW, m_msgPSW);
DDX_Control(pDX, IDC_MSG_OTHER, m_msgOTHER);
DDX_Control(pDX, IDC_MSG_ID, m_msgID);
DDX_Control(pDX, IDC_REGISTER, m_btnRegister);
DDX_Control(pDX, IDC_LOGIN, m_btnLogin);
DDX_Text(pDX, IDC_ID, m_iID);
DDX_Text(pDX, IDC_PSW, m_iPSW);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
//{{AFX_MSG_MAP(CLoginDlg)
ON_WM_CTLCOLOR()
ON_WM_PAINT()
ON_BN_CLICKED(IDC_LOGIN, OnLogin)
ON_BN_CLICKED(IDC_REGISTER, OnRegister)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
void CLoginDlg::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK();
}
void CLoginDlg::OnCancel()
{
// TODO: Add extra cleanup here
nResponse = 0;
CDialog::OnCancel();
}
BOOL CLoginDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_msgID .SetType(1);
m_msgPSW.SetType(1);
m_msgOTHER.SetType(1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
HBRUSH CLoginDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CLoginDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
GetClientRect(&rect);
CBrush * br = new CBrush(RGB(192,192,255));
if ( br ) {
dc.FillRect(&rect,br);
delete br;
}
// Do not call CDialog::OnPaint() for painting messages
}
void CLoginDlg::OnLogin()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString str;
char buff[64];
m_editID.GetWindowText(buff,64);
str.Format("%s",buff);
if(str.GetLength()==0) {
MessageBox("请输入帐号!");
return ;
}
else if(str.GetLength() < 8) {
MessageBox("您输入的帐号不足8位,请重新输入!");
return ;
}
m_editPSW.GetWindowText(buff,64);
str.Format("%s",buff);
if(str.GetLength()==0) {
MessageBox("请输入密码!");
return ;
}
else if(str.GetLength() < 6) {
MessageBox("您输入的密码不足6位,请重新输入!");
return ;
}
nResponse = 1;
CDialog::OnOK();
}
void CLoginDlg::OnRegister()
{
// TODO: Add your control notification handler code here
nResponse = 2;
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -