对话框字符过滤问题
IDC_EDIT1下字符过滤,仅仅16进制允许,如何在编辑框里限制输入只能是16进制数字?
从网上找了点答案,具体是
从CEdit派生一个类,添加WM_CHAR消息映射。
void CMyHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ( (nChar >= '0' && nChar <= '9') ||
(nChar >= 'a' && nChar <= 'f') ||
(nChar >= 'A' && nChar <= 'F') ||
nChar == VK_BACK ||
nChar == VK_DELETE) //msdn的virtual key
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
}
但是具体如何调用呢,
void CToolDlg::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
// 这类如何调用才能让IDC_EDIT1 有这个效果,谢谢
}