tags:

views:

273

answers:

2

How do you add code to these events for native c++. I couldnt 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

A: 

The message you're looking for is WM_KILLFOCUS

BitBank
+2  A: 

JUST BEFORE your window loses focus it will be sent: WM_KILLFOCUS
AFTER your window gains focus, it will be sent: WM_SETFOCUS

I think I know where the confusion lies. You can send a window a message WM_SETFOCUS to set it's focus, but you can also get notified when you got focus by adding custom handling for WM_SETFOCUS and then call the default windows handling.

Brian R. Bondy