title: c# absolute position of control on screen
body: <p>I'm trying to get the absolute position of a control on the screen. I'm using two monitors and the results aren't really that great...</p>
  
  <p>What I'm doing is opening another form to capture an image, then passing this image to the main form and closing the capture form. I then want the main form to appear in the same place the picture was captured. To get a gist of what I'm trying to do as an example, open Snipping Tool on Windows and capture a snip. The window will then appear in the place that the image was taken.</p>
  
  <p>This is the current code I am using to do this:</p>
  
  <pre><code>Location = new Point(Cursor.Position.X - CaptureBox.Width - CapturePanel.Location.X - CaptureBox.Location.X - 8, Cursor.Position.Y - CaptureBox.Height - CapturePanel.Location.Y - CaptureBox.Location.Y - 30);
  </code></pre>
  
  <p>CapturePanel contains the CaptureBox control which stores the picture. I'm also taking 8 from the X location and 30 from te Y location to compensate for the form's border and title bar, but the only problem with this is that some computers will be using a different window style, and these numbers will change.</p>
  
  <p>If there is a method that can be used to grab the border and title width/height of windows, that would be great.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>A solution to this would be:</p>
  
  <pre><code>Location = new Point(
      Cursor.Position.X -
      CaptureBox.Width -
      CapturePanel.Location.X -
      CaptureBox.Location.X - 
      SystemInformation.HorizontalResizeBorderThickness,
      Cursor.Position.Y -
      CaptureBox.Height -
      CapturePanel.Location.Y -
      CaptureBox.Location.Y -
      SystemInformation.CaptionHeight -
      SystemInformation.VerticalResizeBorderThickness
  );
  </code></pre>
  
  <p>With help from King King pointing out SystemInformation to me.</p>