Is there a way to tell whether my application is active i.e. any of its windows has .IsActive=true?
I\'m writing messenger app and want it to flash in taskbar when it is
One way (may be there would be more better ways) can be to find the Active window through Windows API then find the process name of active window.
if(yourProcessName == ActiveWindowProcessName)
{
//your window is in focus
}
Another way could be to keep a reference of all the windows and when you want to find out whether your app is active or not just iterate through all the windows and check IsActive
value
Another way could be to use OwnedWindows
property of MainWindow. Whenever you are creating a new window assign main window it's owner. Then you can iterate all the OwnedWindows
of MainWindow and check whether any is active or not.(never tried this approach)