tags:

views:

67

answers:

3

I have main form and some other forms, that can be shown by controls, placed on the main form, using ShowDialog(control). Also I have event handler on the main form, that can be handled anytime. How can I check inside it, is there any other dialog forms?

A: 

If I understand you correctly, you're asking if inside your main form's event handler, you can check to see if any other forms are open.

If you show these forms using ShowDialog then your main form's thread is blocked until that new form is closed. I believe any events fired during that time will wait, and be handled after the form closes.

If you show these forms using Show then you need to keep some reference to the form in order to check on them during your event handler.

If you word your question a little clearer, maybe I can help more.

Daniel Rasmussen
Sorry, I have some troubles with English.My event handler handles event from another static class (my application is multithreaded and I'm using this static class as shared memory). So it can be called anytime just like simple method. Or may be I am wrong?
dimanyuk
If you're multithreading, then I believe it's possible, as you described. Like Ram said, you can use `form.visible`. Make sure you have proper thread-safe precautions in place, tho, and be sure to save your instance of the form somewhere you can access it in your handler. That is, if you just call `(new MyDialog()).ShowDialog()` you'll have no way to check it's visibility later.
Daniel Rasmussen
A: 

If I understood your question correctly, I would suggest you to check form.visible for each form.

This might help you

Ram
But can't I obtain active form and compare it to main? It would solve my probrlem.
dimanyuk
Check the updated answer.
Ram
I'll read man next time, thanks
dimanyuk
A: 

You might want to have a look at the Application.OpenForms. You can have a look in the collection.

PieterG
Thank you. I forgot to view Application properties.
dimanyuk