拦截文本框的EN_CHANGE事件:void CXXXDlg::OnChangeMd5() { // 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.
ON_COMMAND(ID_EDIT_PASTE, OnPaste)
{
// 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.
CString str;
GetDlgItemText(IDC_XXX,str);
for(int i=0;i<str.GetLength();i++)
{
int b = (int)str[i];
if( b>=0x30 && b<=0x39)
continue;
else
{
SetDlgItemText(IDC_XXX,NULL);
return;
}
}
}
对edit 加个校验 只允许数字
继承CEdit类创建CEditEx类,拦截CEditEx类的WM_RBUTTONUP事件,在菜单弹出前加入标记,拦截CEditEx类的WM_LBUTTONDOWN中重置标记,以处理弹出菜单后未点击菜单项的情况,在void CXXXDlg::OnChangeMd5()中判断是输入还是弹出菜单后的变化,并重置标记即可