How to make a character counter? (Problem with WndProc)

Started by Stas_Rocketman, May 14, 2012, 03:19:48 PM

Previous topic - Next topic

Stas_Rocketman

I've tried to write a simple program, counting characters, which user has typed in edit control. But faced with a problem...
How to make WndProc handle event, when you are typing somethin in that edit? Which event I have to use (such as WM_CREATE, WM_COMMAND or smth else) and how?

RuiLoureiro

Process a button in WM_COMMAND
If we press that button we call a proc
to count the characters.
Is not you want ?

qWord

The control sends the EN_CHANGE (and EN_UPDATE) notification to it's parent (through WM_COMMAND).
FPU in a trice: SmplMath
It's that simple!

Ryan

invoke GetWindowTextLength, lParam

The number of characters typed in the control will be in EAX.

You can also use GetWindowText if you want it to fill an array with the contents.  EAX will have the length.

Stas_Rocketman

Quote from: RuiLoureiro on May 14, 2012, 03:43:12 PM
Process a button in WM_COMMAND
If we press that button we call a proc
to count the characters.
Is not you want ?
Yes, I've already thought about it. But it would be much better, when program counting text length automatically, without pressing any buttons.

Quote from: qWord on May 14, 2012, 03:43:57 PM
EN_CHANGE and EN_UPDATE through WM_COMMAND.
Thanks, qWord, that was exactly what I needed in that program.

Quote from: Ryan on May 14, 2012, 04:47:02 PM
invoke GetWindowTextLength, lParam
The number of characters typed in the control will be in EAX.
You can also use GetWindowText if you want it to fill an array with the contents.  EAX will have the length.
Yeah thanks, I'm already using GetWindowTextLength to get the length of typed text from edit control.

Stas_Rocketman

#5
Okay, here I have attached that program... Maybe it will be useful for somebody :)