News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Limit chars in an editbox

Started by timertik, May 19, 2008, 06:40:23 AM

Previous topic - Next topic

timertik

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Tedd

Or, just send the EM_SETLIMITTEXT message to the edit control.
No snowflake in an avalanche feels responsible.

timertik

#3
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
     

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

timertik

thanks I will check it out  :U