title: How to draw a box around a third party window using c#?
body: <p>How to draw a rectangle around a third party window? I have got the handle to that window and have the size of window. I am  drawing a rectangle around window but that is not attached to the window when I open some other application the same rectangle appears on the top of that application. How to keep it in the background or attached with my window</p>
  
  <p>Code which I am using now</p>
  
  <pre><code>IntPtr desktop = GetDC(IntPtr.Zero);
  while (true)
  {
    using (Graphics g = Graphics.FromHdc(desktop))
    {
      RECT rct = new RECT();
      GetWindowRect(wnd.hWnd, ref rct);
      Rectangle rect = new Rectangle(rct.Left - 2, rct.Top - 2, (rct.Right - rct.Left) + 2, (rct.Bottom - rct.Top) + 2);
      Pen myPen = new Pen(System.Drawing.Color.Red, 5);
      g.DrawRectangle(myPen, rect);
      g.Dispose();
    }
  }
  </code></pre>
  
  <p>Thanks</p>