我做了2个ccombox组合框,我想在一个组合框中禁止输入数字,一个禁止输入除数字外的字符,并限制字数,该怎么做

解决方案 »

  1.   

    响应CBN_EDITCHANGE消息进行相应的字符处理就可以了
      

  2.   

    重载PreTranslateMessage(MSG* pMsg)
      

  3.   

    BOOL CDlgTestDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class              
    if(pMsg->message==WM_CHAR)
    { CWnd *pWnd = GetFocus();//用于确定焦点在对应的ComBoBox上
    if(pWnd != NULL)
    {
    if( pWnd->GetParent() == GetDlgItem(IDC_COMBO1) )
    {
    if(pMsg->wParam >=57 || pMsg->wParam <=48)
    //57,48,这个你可以去查msdn上的Virtual-Key Codes
    return TRUE;
     }
    }  

    //另外一种情况你可以类似的方法实现

        
    return CDialog::PreTranslateMessage(pMsg);
    }