If you edit the text in an editbox on the EN_UPDATE message, by using WM_GETTEXT (perform some editing on the text) put it back to the editbox by using WM_SETTEXT, the problem is that WM_SETTEXT will generate an infinite EN_UPDATE loop. I could use a global variable to signal that it shouldn't update right after it has been updated, but im sure there is a much better solution available. I cannot use EN_CHANGE as it comes after the editbox has been drawn, I need to edit the text before it is displayed.
Do you know a way to get rid of the eternal loop problem?
You should use the EN_CHANGE notification message. It tells you when the user has changed altered the text in the edit box.
EN_CHANGE:
Edit_GetText(CONTROL_ID, &sbuffer, Edit_GetTextLength())
...
Edit_SetText(CONTROL_ID, &sbuffer)
EN_UPDATE is for when it needs to redraw itself. For instance, a user hovers over it, or it needs to be redrawn to include another character the user or system punched in.
you could use a keyboard hook to edit individual characters before they are displayed
MichaelW gives a nice example...
http://www.masm32.com/board/index.php?topic=16427.msg136076#msg136076
although, i am not sure that Horton's method wouldn't do the same thing
Petzold/Doucette: (http://www.jasondoucette.com/books/pw5/pw5errata.html)
QuoteEN_CHANGE Unlike the EN_UPDATE notification message, this notification message is sent after the system updates the screen.
EN_UPDATE The EN_UPDATE notification message is sent when an edit control is about to display altered text. This notification message is sent after the control has formatted the text, but before it displays the text.
Best option seems to set a global variable in EN_UPDATE that is used to suppress action in the EN_CHANGE handler.