Tech Support > Microsoft Windows > Development Resources > text control EN_UPDATE question
text control EN_UPDATE question
Posted by Lee Garrington on December 30th, 2003


Hey,

I have two text controls, one which holds the number of squares that are
occupied in a grid and one which holds the percentage of how many squares in
the grid are occupied.

These two obviously effect each other when you change them and I want them
to update each other as they are updated themselves. The only problem is,
is that everytime you set the text of one to something it calls the
EN_UPDATE event in it recursively.

Is there any way to prevent this from happening? I know you can use
conditions to prevent it from happening but they also cause a few problems.

Cheers


Posted by Norman Bullen on December 30th, 2003


Lee Garrington wrote:
way to prevent it.

What you can do, however, is ignore those EN_UPDATE messages that result
from your SetWindowText(), SetDlgItemText(), and/or WM_SETTEXT operations.

Set a flag before you do any of the above and clear it immediately
after. In your handler for EN_UPDATE, test the flag and ignore the
message when it is set.

static BOOL bFlag = FALSE;

bFlag = TRUE;
SetWindowText(hwndEdit, "new text");
bFlag = FALSE;

case EN_UPDATE:
if (bFlag) break; /* ignore this message */
...
break;

Norm



Similar Posts