The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Stas_Rocketman on May 14, 2012, 03:19:48 PM

Title: How to make a character counter? (Problem with WndProc)
Post by: Stas_Rocketman on May 14, 2012, 03:19:48 PM
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?
Title: Re: How to make a character counter? (Problem with WndProc)
Post by: 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 ?
Title: Re: How to make a character counter? (Problem with WndProc)
Post by: qWord on May 14, 2012, 03:43:57 PM
The control sends the EN_CHANGE (http://msdn.microsoft.com/en-us/library/windows/desktop/bb761676(v=vs.85).aspx) (and EN_UPDATE) notification to it's parent (through WM_COMMAND).
Title: Re: How to make a character counter? (Problem with WndProc)
Post by: 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.
Title: Re: How to make a character counter? (Problem with WndProc)
Post by: Stas_Rocketman on May 15, 2012, 01:04:08 AM
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.
Title: Re: How to make a character counter? (Problem with WndProc)
Post by: Stas_Rocketman on May 25, 2012, 06:12:00 AM
Okay, here I have attached that program... Maybe it will be useful for somebody :)