title: Check if window is a MessageBox
body: <p>I have a function where i can react on appearing windows. Now i want to know if the appearing window is a Messagebox. And if it is one, i want to read the text of it. </p>
  
  <p>I'm already able to extract the Window-Title, Class-Name and Process-Id by</p>
  
  <pre><code>[DllImport("user32.dll", CharSet = CharSet.Unicode)]
  internal static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
  
  [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
  internal static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
  
  [DllImport("user32.dll")]
  internal static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
  </code></pre>
  
  <p>But how can i find out the text of a messagebox? </p>
  
  <p>To get all windows i am using this:</p>
  
  <pre><code>internal static class WindowFinder
      {
      private static readonly List&lt;IntPtr&gt; listWindows = new List&lt;IntPtr&gt;();
  
      private static bool IsWindowOrDialog(IntPtr hwnd, int lParam)
      {
          if (NativeMethods.IsHungAppWindow(hwnd) || !NativeMethods.IsWindowVisible(hwnd))
              return true;
          listWindows.Add(hwnd);
          return true;
      }
  
      internal static IEnumerable&lt;IntPtr&gt; GetAllWindows()
      {
          listWindows.Clear();
          NativeMethods.EnumWindows(IsWindowOrDialog, IntPtr.Zero);
          return listWindows;
      }
  }
  </code></pre>