Popup form should not remain on screen if application is not in focus

Feb 15 2012 7:15 AM
Hi,

I am working on windows form using C#/.NET 3.5. I have a main form(frm1) which contains a button(btn1). After click on btn1 a new popup form(frm2) will open. frm2 has "TopMost" property value as true.When i click on btn1 "frm2.Show" method calls(as per requirements, we are not calling "ShowDialog" method ) and frm2 will open as popup. we are using "frm1__Resize" event to handle the minimization and maximization of both form simultaneously. Everything is going fine.

But a problem occurs when i click on another application(as Excell sheet) the frm2 still remains there as its "TopMost" property is true. i want to hide my frm2 form if my application is not on focus. Is there any event for that(I tried, but not able to find the event , which will fire when application is not in focus)? Please help me out regarding this problem.

Your any suggestion will help me, Thanks in advance.

Answers (1)