` Printed Icetips Article

Icetips Article



Par2: Limiting number of characters entered in a field
2006-12-15 -- Larry Sand
 
If you want to limit the text box to n characters you can send it the Edit 
Message: EM_LIMITTEXT Like this:

SendMessage(hWndText, EM_LIMITTEXT, nTextLimit, 0)

hWndText is the handle to the text box, ?textbox{Prop:Handle}
EM_LIMITTEXT        EQUATE(00C5h)
nTextLimit is the number of characters.

This does not require that you subclass the text box.

If you want to know the number of characters as they're typed you can 
subclass the control and watch for the Edit Notification message EN_CHANGE. 
Edit notification messages are sent in a WM_COMMAND message.



Printed May 1, 2024, 11:10 pm
This article has been viewed/printed 35123 times.