Kosmo零
Kosmo零

Reputation: 4151

How to check in .net if program's main form doesn't have any modal forms opened?

Let's say I have some threads running there. They must perform some actions only if no modal forms shown over main form.

I don't want to add hack checks like setting some flag before opening some modal form. Is there any generic way?

Upvotes: 0

Views: 29

Answers (1)

Backs
Backs

Reputation: 24903

We use this hack:

if (this.Visible && !this.CanFocus)
{
    //another modal window is opened
}

But you should know, that modal window "blocks" main form execution. And you can check this only in some cases, like repainting.

Upvotes: 1

Related Questions