title: C# Close child form if it lost focus but not if application is not active
body: <p>How can I close the dialog (form) when it loses its activity (focus), but not close if you switch to another application, desktop and etc? </p>
  
  <p>So far i use this code: </p>
  
  <p><code>private void MyDialog_Deactivate(object sender, EventArgs e)
  {
     Close();
  }</code></p>