3

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?

Vlad Gudim
  • 23,397
  • 16
  • 69
  • 92
Game_Overture
  • 1,578
  • 3
  • 22
  • 34

2 Answers2

1

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
  • 3,120
  • 1
  • 34
  • 57
1

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
  • 2,196
  • 14
  • 15