To disable spaces entering textbox
In MFC开发者_C百科 How to disable spaces entering textbox
Just supply the own OnKeyDown event handler and filter out the space keys:
void MyEditControl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == 32)
{
// kill the space key down event
return;
}
// let edit control handle the other keys
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
you can update the user entry on OnChangeControl as follows:
if ((m_strYOURCONTROL[m_strYOURCONTROL.GetLength() - 1]) == ' ')
{
m_strYOURCONTROL = m_strYOURCONTROL.Mid(0, m_strYOURCONTROL.GetLength() - 1);
}
精彩评论