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")); } }
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"));
}
}
VisualEleven 十分感谢你帮我解决了listctrl选择item顺序的问题.
这个判断条件很精妙 _istdigit()这种API不知道你平时是怎么收集的.还记的这么牢
现在VC6兼容UNICODE写成了 _istdigit,MSDN有写