title: Check if any dialog is open
body: <p>Does anybody see my mistake here?</p>
  
  <p>I am unable to recognize if a form is shown as a dialog in my app.</p>
  
  <pre><code>Public Class Form1
  
    Private m As Form2
  
    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
      Me.Text = DateTime.Now.ToLongTimeString &amp; " " &amp; IsAnyDialogShown()
    End Sub
  
    Public Function IsAnyDialogShown() As Boolean
      For Each f As Form In Me.OwnedForms
         If f.Owner Is Me Then
           Return True
         End If
      Next
    End Function
  
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
      m = New Form2
      m.ShowDialog()
    End Sub
  
  End Class
  </code></pre>