开发者

How to limit number of characters typed in a textbox in MFC?

开发者 https://www.devze.com 2022-12-19 21:25 出处:网络
I have 2 questions...my 1st question is how do I limit the number of character typed in a textbox in MFC..say if I want the user to type only 4 characters..the text box should take only 开发者_JAVA技巧

I have 2 questions...my 1st question is how do I limit the number of character typed in a textbox in MFC..say if I want the user to type only 4 characters..the text box should take only 开发者_JAVA技巧4 character.And my 2nd question is when it exceeds the character limit it should jump to the next textbox/tab control.I tried using the following code..but it seem to not work in my case...Please help me if you know any alternatives...

CEdit::SetLimitText(4);


handle the EN_CHANGE message (OnEnChange). In that handler, find the number of chars the textbox has. If it's more than 4, remove the last ones. If it's four, use NextDlgCtrl() to tab to the next control or use SetFocus() to set the focus to a specific control.

0

精彩评论

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