开发者

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜