Game.Activated Not Always Firing

When the game is minimized / in the background and you use the task bar to bring it into focus the Game.Activated event very often does not fire. Rather what happens is when you minimize the game using the task bar the Activated event is fired immediately after the Deactivated event even though the window is actually minimized. So when you click the icon in the task bar again to reactivate it, the Activated event does not fire again.

This appears to be a problem in windows forms itself.

XNA gets around it by using WndProc like this:

        protected override void WndProc(ref System.Windows.Forms.Message m)
            if (m.Msg == 0x1c)
                bool active = m.WParam != IntPtr.Zero;
            base.WndProc(ref m);


Actually it appears XNA has the same issue, however, it hooks up to the Form.Resize event which triggers a graphics device reset and ends up calling the Activated event so it works out.