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.
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.
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.
The message you're looking for is WM_KILLFOCUS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With