/// <summary> /// Calculates total width of control buttons (minimize, maximize, close). /// </summary> /// <param name="handle">Window handle.</param> /// <returns>Total width in pixels.</returns> private static int GetControlAreaWidth(IntPtr handle) { WindowStyle style = new WindowStyle(handle); int buttonCount = style.MaximizeBox || style.MinimizeBox ? 3 : 1; int controlButtonAverageWidth = ApiSystemMetrics.Get(SystemMetric.SM_CXSIZE); return(controlButtonAverageWidth * buttonCount); }