在EditBox里面设置只能输入两位数字然后自动跳到下一个编辑框,怎么实现?

解决方案 »

  1.   

    感觉应该是响应 ON_EN_CHANGE 消息来处理
      

  2.   


    void CMFCTestDlg::OnChangeEdit1() 
    {
    CString str;
    GetDlgItemText(IDC_EDIT1, str); if (str.GetLength() => 2)
    ::SetFocus(GetDlgItem(IDC_EDIT2)->m_hWnd); //假如下一个编辑框的ID是IDC_EDIT2
    }
      

  3.   


    if (str.GetLength() => 2)改if (str.GetLength() >= 2)一时疏忽。
      

  4.   

    void CMFCTestDlg::OnChangeEdit1() 
    {
         CString str;
         GetDlgItemText(IDC_EDIT1, str);
         
         GetNextDlgTabItem(GetDlgItem(IDE_EDIT1),FALSE)->SetFocus();
    }
      

  5.   

    void CMFCTestDlg::OnChangeEdit1()  
    {
      CString str;
      GetDlgItemText(IDC_EDIT1, str);
      if(str.GetLength()>2)
      {
        GetNextDlgTabItem(GetDlgItem(IDE_EDIT1),FALSE)->SetFocus();
      }
    }
    你看可以吗?
      

  6.   


    if (str.GetLength() >= 2)
    {
    ((CEdit*)GetDlgItem(IDC_EDIT2))->SetFocus();
    ((CEdit*)GetDlgItem(IDC_EDIT2))->SetSel(0, -1);
    }