我是MFC的新手。我通过生成自己的CEdit
类CMYEditEx
动态创建了Edit Box,它已经在对话框中创建了编辑框,但是它没有任何数值。我只想为数字设置编辑框。
我无法在编辑框中写任何东西,但我的目的是创建仅采用数字值的编辑框。此功能在OnItDlg
CMYEditEx* pEdit = new CMYEditEx;
pEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER ,
CRect(130, aSize, 260, bSize), this, 1);
BOOL CMYEditEx::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
int nTextLength = this->GetWindowTextLength();
if (pMsg->message == WM_CHAR)
{
// Ignoring 0 to 9
if ((pMsg->wParam >= '0' && pMsg->wParam <= '9'))
{
return true;
}
}
return CEdit::PreTranslateMessage(pMsg);
}