1.假如先显示密码验证框,密码正确后,才显示其它的对话框,现在的问题就是假如关闭密码验证框,其它的对话框还是能够显示出来了。我要的是关闭了密码验证框,其它的对话框也就不显示了,怎么搞。void Cmydlg::OnOK() 密码验证框。
{ static int nTimes=0;
UpdateData(TRUE);
if(m_edit=="123")
{ nTimes=0;}
else
{ nTimes++;
CString string;
if(nTimes>=3)
{ AfxMessageBox(密码错误三次,关闭);
exit(0);
}
AfxMessageBox(密码错误,再输入);
return ;
}
CDialog::OnOK();
}
主对话框BOOL CContactBookDlg::OnInitDialog()
{
CDialog::OnInitDialog();
**********
Cmydlg dlg;
if(dlg.DoModal()==IDOK)
{*****}
return TRUE;
}是不是那里需要添加代码的。
2.在static控件怎么使字符分行的,例如:请输入密码,限于三次,\n开始为123.
好象这样不能分的。
{ static int nTimes=0;
UpdateData(TRUE);
if(m_edit=="123")
{ nTimes=0;}
else
{ nTimes++;
CString string;
if(nTimes>=3)
{ AfxMessageBox(密码错误三次,关闭);
exit(0);
}
AfxMessageBox(密码错误,再输入);
return ;
}
CDialog::OnOK();
}
主对话框BOOL CContactBookDlg::OnInitDialog()
{
CDialog::OnInitDialog();
**********
Cmydlg dlg;
if(dlg.DoModal()==IDOK)
{*****}
return TRUE;
}是不是那里需要添加代码的。
2.在static控件怎么使字符分行的,例如:请输入密码,限于三次,\n开始为123.
好象这样不能分的。
{
CDialog::OnInitDialog();
....
//Message( "请输入密码,登陆系统。" );CPassword dlgPasswd;
if( dlgPasswd.DoModal() == IDCANCEL )
{
CDialog::EndDialog( FALSE );
return TRUE;
}
...
return TRUE; // return TRUE unless you set the focus to a control
}static控件中的文本使用\n进行分行,如SetDlgItemText( IDC_STATIC_TXT, "123\n456\n789" );当然,你的static控件不能有Center vertically属性。
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif Cmydlg dlgMM; //验证密码对话框
dlgMM.DoModal();
if (!dlgMM.m_flag)
return FALSE; //密码不对,退出程序
CContactBookDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
{*****}
else
PostQuitMessage(0);