views:

468

answers:

2

I need to know when my Window goes out of input focus, so I overloaded the OnKillFocus() method of the CWnd.

However it doesn't invoke this method when I focus another application (alt+tab), or even minimize the window. But it DOES invoke the method when I restore it from being minimized. Are these the intended times for it to trigger this method?

+1  A: 

I think you'll need a CWnd::OnActivateApp() handler if you need to be sure of being notified when your application is switched out.

jeffm
+1  A: 

OnKillFocus() is normally only used consistently for controls that have a concept of gaining the focus - buttons, edit boxes, list boxes, etc. Normally CWnd does not accept the focus, so you can't rely on that - I'm surprised you get it at all.

In addition to WM_ACTIVATEAPP mentioned above, there's also WM_ACTIVATE when switching between windows within the same application you might want to trap.

JTeagle