title: ClientToScreen unexpected return values?
body: <p>I never worked with windows before. I put a lot of effort into getting the correct X and Y coordinates and size of a windows, aswell as the size of the client-area of the window.</p>
  
  <p>Unfortunately, X and Y of the client-area is always zero. I looked it up in the documentation and it is supposed to be zero.</p>
  
  <p>On SO, I found that I need to translate the client-are coordianted to the screen coordinates by passing it to <code>ClientToScreen()</code>. However, the results are not what I expect them to be.</p>
  
  <p>Instead of a Point(50,50) (or similar), I get a Point(1,57027688545264E-312, 0).</p>
  
  <p>Could someone enlighten me on what's wrong?</p>
  
  <p>This is my code, so far:</p>
  
  <pre><code>    [DllImport("user32.dll")]
      [return: MarshalAs(UnmanagedType.Bool)]
      static extern bool GetClientRect(IntPtr hWnd, out Rect rect);
  
      [DllImport("user32.dll")]
      static extern bool ClientToScreen(IntPtr hWnd, ref System.Windows.Point lpPoint);
  
      [StructLayout(LayoutKind.Sequential)]
      public struct Rect
      {
          public int Left;
          public int Top;
          public int Right;
          public int Bottom;
      }
  
      static Rectangle GetClientRect(IntPtr handle)
      {
          Rect rect;
          GetClientRect(handle, out rect);
          System.Windows.Point p = new System.Windows.Point(0, 0);
          ClientToScreen(handle, ref p);
          rect.Left = (int)p.X;
          rect.Top = (int)p.Y;
          return new Rectangle(rect.Left, rect.Top, rect.Right, rect.Bottom);
      }
  </code></pre>