在使用C#制作Winform窗体时候,如果自定义窗体外观,需要对于Form做圆角处理,使得窗体更加美观。进行圆角处理的方法如下:
/// <summary>
/// 去除Form的四角,使其变成圆角显示。切去3像素的大小。
/// <para>注意:使用此方法,要设置Form的BackgroundImageLayout属性为Stretch。</para>
/// <para>未设置的情况下,会产生页面闪烁。</para>
/// </summary>
/// <param name="form"></param>
public static void Paint(Form form)
{
var list = new List<Point>();
int width = form.Width;
int height = form.Height;
//左上
list.Add(new Point(0, 2));
list.Add(new Point(1, 2));
list.Add(new Point(1, 1));
list.Add(new Point(2, 1));
list.Add(new Point(2, 0));
//右上
list.Add(new Point(width - 2, 0));
list.Add(new Point(width - 2, 1));