ON_EN_KILLFOCUS called multiple times
Question
I am using a CEdit control. And I have assigned an event handler for ON_EN_KILLFOCUS message. It gets called correctly. But the problem is that, when ever, I close the dialog box, this event handler gets called four times. How can I prevent this?
Solution
Why try to prevent it? Just make sure your handler ignores the ones that don't matter -
OTHER TIPS
Just ran into similar issue and solved by separating to different handlers.
I was using:
ON_EN_KILLFOCUS(IDE_THRESHOLD, OnKillFocusOnEdit)
ON_EN_KILLFOCUS(IDE_AUTODENY_THRESHOLD, OnKillFocusOnEdit)
OnKillFocusOnEdit
will receive two messages every time either of these two edits lose focus.
Now by changing to following, each function receives only one message as expected:
ON_EN_KILLFOCUS(IDE_THRESHOLD, OnKillFocusOnEdit)
ON_EN_KILLFOCUS(IDE_AUTODENY_THRESHOLD, OnKillFocusOnAutoDenyEdit)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow