News:

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

Prevent EN_UPDATE loop problem

Started by zemtex, August 09, 2011, 02:11:00 PM

Previous topic - Next topic

zemtex

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?
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

Twister

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.

dedndave

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

jj2007

Petzold/Doucette:
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.