How to check if the ShowDialog () open form form is open?

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

At some point, I can open the AuxForm form with ShowDialog (), and then, while the modal form is open, another thread is still modifying the MainForm properties. All this is necessary.

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

NOTE. None of these properties / methods modify the controls (therefore Invoke is not required).

+3
source share
2 answers

Well, a flag would probably be a better idea. But just to convey some useless information, when the window shows a modal dialog, Window styles change to enable WS_DISABLED, basically this window is disabled, so you can check if the window is disabled.

+3
source

maybe this can help ... after you have all the application windows open, you can search the collection for your target window. You can determine if a form is modal by checking its Modal property .

+1
source

Source: https://habr.com/ru/post/1746525/


All Articles