Exemple #1
0
        private static void HighlightRect(Rectangle rect)
        {
            SystemWindow window = SystemWindow.DesktopWindow;

            using (WindowDeviceContext windowDC = window.GetDeviceContext(false))
            {
                using (Graphics g = windowDC.CreateGraphics())
                {
                    g.DrawRectangle(Pens.Blue, rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2);
                }
            }
        }
 /// <summary>
 /// Highlights the window with a red border.
 /// </summary>
 public void Highlight()
 {
     RECT rect;
     GetWindowRect(_hwnd, out rect);
     using (WindowDeviceContext windowDC = GetDeviceContext(false))
     {
         using (Graphics g = windowDC.CreateGraphics())
         {
             g.DrawRectangle(new Pen(Color.Red, 4), 0, 0, rect.Right - rect.Left, rect.Bottom - rect.Top);
         }
     }
 }