title: SetWindowPos not working for browsers - no MainWindowHandle?
body: <p>I've been trying to make a simple program in C#, to launch different software, and move it to a specific screen, to be able to automatically set up different windows, on a machine with a total of 12 monitors.</p>
  <p>Most of these windows is launched in either Chrome or Internet Explorer.</p>
  <p>The code I use to move the appplications is the following:</p>
  <pre><code>[DllImport(&quot;User32.dll&quot;)]
  static extern int SetForegroundWindow(IntPtr hWnd);
  
  [DllImport(&quot;user32.dll&quot;, EntryPoint = &quot;SetWindowPos&quot;)]
  public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
  
  this.process = Process.Start(this.startInfo);
  process.WaitForInputIdle();
  SetForegroundWindow(this.process.MainWindowHandle);
  
  Console.WriteLine(&quot;Process ID: &quot;+ this.process.Handle);
  this.process.Refresh();
  Console.WriteLine(&quot;Main window handle: &quot; + this.process.MainWindowHandle);
  
  Point screenlocation = Screen.AllScreens[MonitorNum].Bounds.Location;
  SetWindowPos(this.process.MainWindowHandle, -1, screenlocation.X, screenlocation.Y, Screen.AllScreens[MonitorNum].Bounds.Width, Screen.AllScreens[MonitorNum].Bounds.Height, 1);
  </code></pre>
  <p>It seems to be working just fine with Notepad, but when it's a browser MainWindowHandle always return IntPtr.Zero, even if I refresh the Process.</p>
  <p>Any advice?</p>