CEdit文本框中只允许输入数字,把属性Number设为TURE,就可以只输入数字了!
在其他地方复制非数字,往Cedit文本框中粘贴,可以粘贴非数字;
怎么判断粘贴的是非数字?

解决方案 »

  1.   

    EM_CHANGE消息:
    void CXXXDlg::OnChangeEdit1() 
    {
    // TODO: If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CDialog::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.

    // TODO: Add your control notification handler code here
    CString str(_T(""));
    GetDlgItemText(IDC_EDIT1, str);
    BOOL bOK = TRUE;
    for(int i=0; i<str.GetLength(); i++)
    {
    if(!_istdigit(str.GetAt(i)) || str.GetAt(i) == _T('.'))
    {
    bOK = FALSE;
    break;
    }
    }
    if(!bOK)
    {
    AfxMessageBox(_T("NO number"));
    }
    }
      

  2.   


    VisualEleven 十分感谢你帮我解决了listctrl选择item顺序的问题.
    这个判断条件很精妙 _istdigit()这种API不知道你平时是怎么收集的.还记的这么牢
      

  3.   

    楼主,isdigit() 是C语言书里有教的.
    现在VC6兼容UNICODE写成了 _istdigit,MSDN有写