Tutorial :How to check whether the form has any ShowDialog() forms open?


I have a form MainForm with several properties/methods that are accessed from another thread.

At some point I might open a form AuxForm with ShowDialog() and then while that modal form is open, the other thread still modifies the MainForm's properties. This is all desired.

In one of the methods accessed from another thread I need to execute some code, but only if the modal AuxForm is not open. Is there any way to check this (by using .NET WF Form properties) or I need to use a flag variable?

NOTE: None of these properties/methods modify the controls (so no Invoke is required).


Well a flag would probably be the best idea. But just to also pass on some useless information, when a window shows a modal dialog the Window Styles are modified to include WS_DISABLED, basically the window is disabled, so you can check if the window is disabled.


maybe this can help... once you have all the opened windows of the application you can search the collection for your target window. You can tell if a form is modal by checking it`s Modal property.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »