Detect Opened Forms
-
I'm creating and opening new forms from a main form, set its name randomly and call Form.Show() method to show it. Now the problem is how can i detect if user has closed that form or it's still opened? or its closed and disposed. Thanks in advance!!! Best Regards, Rizwan
-
I'm creating and opening new forms from a main form, set its name randomly and call Form.Show() method to show it. Now the problem is how can i detect if user has closed that form or it's still opened? or its closed and disposed. Thanks in advance!!! Best Regards, Rizwan
-
Thanks for your interest in helping me. But I think it's not effecient way that I maintain my own global list to count the opened forms. I hope that C# will be having some built in solution for that. Best Regards, Rizwan Ahmed
-
Thanks for your interest in helping me. But I think it's not effecient way that I maintain my own global list to count the opened forms. I hope that C# will be having some built in solution for that. Best Regards, Rizwan Ahmed
In my opinion keeping a list of references wouldn't be that inefficient. Anyway, as far as I know there is no .NET way to interact with a form you have no refernce for. Maybe there is one since 2.0 but i haven't used it until now. If not, keep a look at the
findwindow
function which you can pinvoke.
-
Thanks for your interest in helping me. But I think it's not effecient way that I maintain my own global list to count the opened forms. I hope that C# will be having some built in solution for that. Best Regards, Rizwan Ahmed
Why should C# care how many forms you create and what you do with them? Each Form is an instance of a class like thousands of other instances. You want your forms to do something meaningful so you'll have to see to it yourself. Regards, mav -- Black holes are the places where god divided by 0...
-
In my opinion keeping a list of references wouldn't be that inefficient. Anyway, as far as I know there is no .NET way to interact with a form you have no refernce for. Maybe there is one since 2.0 but i haven't used it until now. If not, keep a look at the
findwindow
function which you can pinvoke.
Thanks, I'm using 2.0 and also know about findwindow and used it in the same application but some other purpose. Lets see if i can get some better solution otherwise i know different ways to do it. Thanks alot!!! Best Regards, Rizwan