Login dlg;
if(dlg.DoModal()!=IDOK)
{
OnOK();
}
void Login::OnOK()
{
// TODO: Add extra validation here
//CEdit *pEdit1 = (CEdit *)GetDlgItem(IDC_EDIT1);
//CEdit *pEdit2 = (CEdit *)GetDlgItem(IDC_EDIT2);
//CString e1, e2;
//pEdit1->GetWindowText(e1);
//pEdit2->GetWindowText(e2);
//if(e1=="蟒蛇软件站" && e2 == "pythonschool")
//{
// CDialog::OnOK();
//}
UpdateData(TRUE); //数据交换
if(m_Name.IsEmpty() || m_Password.IsEmpty())
{
MessageBox("用户名或密码不能为空");
return;
}
num++; if(num == 3) { MessageBox("Password was error three times"); CDialog::OnCancel(); return; }
if(m_Name=="蟒蛇软件站" && m_Password == "pythonschool")
{
CDialog::OnOK();
}
else
{
MessageBox("用户名或密码不正确");
m_Name = "";
m_Password = "";
UpdateData(FALSE);
return;
}
}
BOOL Login::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CStatic *pStatic1 = (CStatic *)GetDlgItem(IDC_STATIC1);
CStatic *pStatic2 = (CStatic *)GetDlgItem(IDC_STATIC2);
pStatic1->SetWindowText("用户名:");
pStatic2->SetWindowText("密 码:"); num = 0; //设置窗口始终在最上面 CRect rect; GetWindowRect(&rect); ::SetWindowPos(m_hWnd, HWND_TOPMOST, rect.left, rect.top, 0, 0,SWP_NOMOVE||SWP_NOSIZE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
原文链接: https://www.cnblogs.com/pythonschool/archive/2012/11/15/2770307.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/69473
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!