I need help limiting the input aloud in an edit box I want 8 chars but if it goes over 8 I still want to keep the ones that are in the box already.
I thought about this one for a long time and I actually have no clue how to do this. :eek
thank you for your time
timertik,
The trick is to subclass the edit control so you can filter, limit or modify what is being typed and what is already in the control in terms of text. A subclass procedure is like an intercept to the underlying message handling procedure for a control and there is a tool in the masm32 project for creating control subclass procedures.
Once you have the subclass up and running you would process the WM_CHAR message while being able to access the entire text in the control. If its already the maximum you want you don't acept the keystroke. You would normally allow a backspace so that the text can be reduced if it has reached the maximum.
Or, just send the EM_SETLIMITTEXT message to the edit control.
Its not working :/
can you tell me what I have done wrong
.elseif message==EDIT1
invoke SendMessage,hwnd,EM_SETLIMITTEXT,8,0
I figured it out :U
invoke GetDlgItem, hwnd, 1008
mov hWndofEdit, eax
invoke SendMessage, hWndofEdit, EM_SETLIMITTEXT, amount, 0
thanks
just when I use that the text already entered or entered by the app its self doesnt get limited and I dont understand the first post well enough to get it to work I hope to hear something soon thank you both
I have the subclass but I dont know how to use WM_CHAR correctly and msdn wasnt very helpful either :boohoo:
if you could help me out when you have the time I would appreciate it , thanks
timertik,
There is an example in the early example code in the masm32 project called FILTINPT that shows how to subclass a number of edit controls. The first method will be closer to what you need but you will be testing the length of the string not its content.
thanks I will check it out :U