Wednesday, August 29, 2012

How to find if child window is opened or not

How to find if child window is opened or not

I have a requirement where I need to check whether any records have changed, depending on that I need to alert user. So using timer for every 5 sec I am trying to verify from database and showing alert window to the user. working great.

the problem is that, if the user stays idle for a long time. I am getting multiple alert windows as time pass on.(considering data changes for every 2 sec).

So I need to know if the alert window is already opened, How can get the instance of the opened window where I can either do some operation on it.

Answers & Comments...

Answer: 1

Create your child window as a singleton in your application (declare private member) then open and close it accordingly and make sure to release your instance (equals to null). With that in place you just have to check if your "subwindow" is different from null that means it is open if not then you create an instance and open it.

by : Xtian Macedohttp://stackoverflow.com/users/1122144

Answer: 2

You can enumerate through Application.Current.Windows(includes all windows created by your application). You can either find your alert window there and bring it to foreground or create new one.

by : ChrisDDhttp://stackoverflow.com/users/930211




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog