problem getting WM_KILLFOCUS

In the main window callback function I get the WM_KILLFOCUS message when I click on the window, and only then I get the WM_SETFOCUS message.
Is that OK?
I thought that WM_KILLFOCUS message is sent to a window immediatly before it looses focus.
I want to register some values when the window has keyboard focus and unregister the values when the window looses focus.
How can I do that?

Just use a boolean flag. Set it to true when SetFocus has been called, False when KillFocus has been called.

Only de-register them in KillFocus if the flag has been set to true by SetFocus.

Flagging code is generally an anti-pattern. But so are Microsoft's API Callbacks :P
Topic archived. No new replies allowed.