做登录~~~错误了 要弹出对话框提示~~~提示后仍然可以继续跳转到登录页面
int count = 0; 
while (1) 

  CLoginDlg dlg(this); 
  if (dlg.DoModal() == IDOK) 
  { 
    if (用户名&&密码) 
      break; 
    else 
    { 
      count++; 
      if (count > 3) 
        //次数太多,退出 
    } 
  } 

 
 

解决方案 »

  1.   

    int count = 0;
    BOOL Is=FALSE 
    while (count<3 && ! Is) 

      CLoginDlg dlg(this); 
      if (dlg.DoModal() == IDOK) 
      { 
        if (用户名&&密码) 
          Is=TRUE; 
        else 
          count++; 
       } 

    if(! Is)
      return;
      

  2.   

    不在意的话,可以用goto,goto在这里用 会显的很好理解,而且也是近距离goto
      

  3.   

    不需要while循环,在dlg的onoK函数中处理,就可以.//dlg的构造函数
    test_logoin::test_logoin(CWnd* pParent /*=NULL*/)
    : CDialog(test_logoin::IDD, pParent)
    {
    //{{AFX_DATA_INIT(test_logoin)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
       count = 0; }
    void test_logoin::OnOK() 
    {
        // TODO: Add extra validation here
        if (用户名&&密码)
        { 
          CDialog::OnOK(); 
        }
        else 
        { 
          count++; 
          if (count > 3) 
            //次数太多,退出 
        }  
    }