title: How to restore a hidden window?
body: <p>I'm trying to be able to hide a window by clicking a button. Then when I click another, it restores.</p>
  
  <p>This is the code I use to hide the window (Using Notepad as an example):</p>
  
  <pre><code>    private void button_Click(object sender, RoutedEventArgs e)
      {
          int hWnd;
          Process[] processRunning = Process.GetProcesses();
          foreach (Process pr in processRunning)
          {
              if (pr.ProcessName == "notepad")
              {
                  hWnd = pr.MainWindowHandle.ToInt32();
                  ShowWindow(hWnd, 0);
              }
          }
      }
  </code></pre>
  
  <p>But when I try to use this code to restore it, it won't work:</p>
  
  <pre><code>    private void button1_Click(object sender, RoutedEventArgs e)
      {
          int hWnd;
          Process[] processRunning = Process.GetProcesses();
          foreach (Process pr in processRunning)
          {
              if (pr.ProcessName == "notepad")
              {
                  hWnd = pr.MainWindowHandle.ToInt32();
                  ShowWindow(hWnd, 5);
              }
          }
      }
  </code></pre>
  
  <p>There are no exceptions or anything, it just doesn't do anything.
  EDIT: I have used different nCmdShow integers. Those being 1,5 and 9.</p>