Reputation: 54193
How do you add code to these events for native c++?
I couldn't find a WM_LOSTFOCUS
OR WM_GOTFOCUS
; I only found WM_SETFOCUS
. I need code to happen when my window loses focus, and regains it.
Thanks.
Upvotes: 6
Views: 9262
Reputation: 57318
For an edit control, WM_KILLFOCUS
won't work.
Took me too long to figure out that I needed EN_KILLFOCUS. Hopefully saves the next guy some time.
Upvotes: 3
Reputation: 347586
JUST BEFORE your window loses focus it will be sent: WM_KILLFOCUS
AFTER your window gains focus, it will be sent: WM_SETFOCUS
Sending a WM_SETFOCUS message does not set the focus. You need to call SetFocus for that.
Upvotes: 15
Reputation: 374
You may consider WM_ACTIVATE as well. When main window is concerned, activation message could be the only solution.
Upvotes: 0