views:

73

answers:

2

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).

A: 

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.

Chris Taylor
A: 

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.

Alex Pacurar
Too bad I need this for Windows Mobile, and .NET CF's Application does not have such property. Thanks anyway.
kornelijepetak