private static IntPtr ComputeRoundRectRegion(int left, int top, int width, int height, int cornerRadius) { var nWidthEllipse = (int)(2 * cornerRadius * DpiHelper.LogicalToDeviceUnitsScalingFactorX); var nHeightEllipse = (int)(2 * cornerRadius * DpiHelper.LogicalToDeviceUnitsScalingFactorY); return(NativeMethods.CreateRoundRectRgn(left, top, left + width + 1, top + height + 1, nWidthEllipse, nHeightEllipse)); }