Reputation: 1055
Is it possible to do single-character textbox? In other words, after entering 1 character it must not enter other characters that user will be typing;
Upvotes: 2
Views: 1557
Reputation: 769
Yes, you can limit length of text in textbox by sending EM_SETLIMITTEXT message. If you need single character limit :
const int maximum_length = 1;
SendMessage(hEdit, EM_SETLIMITTEXT, maximum_length, 0);
note: EM_LIMITTEXT
and EM_SETLIMITTEXT
are identifiers for the same message. They are constants with same numeric value. Two identifiers exist for historical reasons. (EM_SETLIMITTEXT
is new from Win95/WinNT 4.0 SDK)
Upvotes: 2
Reputation: 1645
For edit use EM_LIMITTEXT (or equivalent EM_SETLIMITTEXT) message. For richedit you need EM_LIMITTEXT or EM_EXLIMITTEXT for text length values greater than 64000
If you use mfc than you need CEdit::LimitText or CRichEditCtrl::LimitText
Upvotes: 5