0

I want to create an application that closes one of it's window when the user clicks on another application (or in other words the application loses focus or inactive). All the windows in my application to have the property TopMost = true.

How I can do that?

your help is greatly appreciated.

Edit (Update):

I need when I click on another window in my application, the window is not closed. Only when my application loses focus (the user clicks on another application), the window will be closed.

Daniel
  • 471
  • 5
  • 28
user3332360
  • 105
  • 8

1 Answers1

0

Check out the Deactivate event, or override OnDeactivate:

protected override void OnDeactivate(EventArgs e)
{
    Close();
}
ikkentim
  • 1,639
  • 15
  • 30
  • it works. But I need when I click on another window in my application, the window is not closed. Only when my application loses focus (the user clicks on another application), the window will be closed. Do you know how to do that? – user3332360 Mar 12 '14 at 12:21