public static extern IntPtr GetWindowRect(IntPtr hwnd, ref NativeStructs.RECT rc);
public void Highlight() { NativeStructs.RECT windowRect = new NativeStructs.RECT(0, 0, 0, 0); NativeMethods.GetWindowRect(handle, ref windowRect); IntPtr windowDC = NativeMethods.GetWindowDC(handle); if (windowDC != IntPtr.Zero) { Graphics graph = Graphics.FromHdc(windowDC, handle); graph.DrawRectangle(highlightPen, 1, 1, windowRect.Width - 2, windowRect.Height - 2); graph.Dispose(); NativeMethods.ReleaseDC(handle, windowDC); } }