限定Edit Control的值(MFC)

BOOL CXXDlg::PreTranslateMessage(MSG* pMsg) 
{
    // TODO: Add your specialized code here and/or call the base class
    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
    ASSERT(pEdit && pEdit->GetSafeHwnd());
    if((WM_KEYDOWN == pMsg->message) && (pEdit->GetSafeHwnd() == pMsg->hwnd))
    {
        if((pMsg->wParam >= _T('0') && pMsg->wParam <= _T('9'))
            || ((pMsg->wParam >= VK_NUMPAD0) && (pMsg->wParam <= VK_NUMPAD9))
             || (_T('*') == pMsg->wParam) || (_T('#') == pMsg->wParam)
             || (VK_LEFT == pMsg->wParam) || (VK_RIGHT == pMsg->wParam)
             || (VK_UP == pMsg->wParam) || (VK_DOWN == pMsg->wParam)
             || (VK_DELETE == pMsg->wParam) || (VK_BACK == pMsg->wParam))
        {
            return CDialog::PreTranslateMessage(pMsg);
        }
        else
        {
            return TRUE;
        }
    }
    return CDialog::PreTranslateMessage(pMsg);
}

 


你可能感兴趣的:(delete,Class,mfc,UP)