输入文本框
答
您可以按如下更新OnChangeControl用户条目:
if ((m_strYOURCONTROL[m_strYOURCONTROL.GetLength() - 1]) == ' ')
{
m_strYOURCONTROL = m_strYOURCONTROL.Mid(0, m_strYOURCONTROL.GetLength() - 1);
}
答
只需提供自己的的onkeydown事件处理程序,并筛选出空格键:
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);
}
[MFC控件在vC++中禁用mfc文本框中的输入空格](http://stackoverflow.com/questions/442635 1/mfc-control-disable-entering-spaces-in-mfc-textbox-in-vc) – Adnan 2010-12-13 13:05:19