1.引用 using System.Runtime.InteropServices;
2.
[DllImport("gdi32")]
private static extern IntPtr CreatePolygonRgn(Point[] lpPoint,int nCount,int nPolyFillMode);
[DllImport("user32")]
private static extern IntPtr SetWindowRgn(IntPtr hWnd,IntPtr hRgn,bool bRedraw);
const int WINDING = 2;
3.创建形状
private void Form1_Load(object sender, System.EventArgs e)
{
Point[] pt={
new Point(this.Width /2,0),
new Point(0,this.Height/2),
new Point(this.Width/2,this.Height),
new Point(this.Width,this.Height/2),
new Point(this.Width,0)
};
IntPtr m_rgn;
m_rgn=CreatePolygonRgn(pt,5,WINDING);
SetWindowRgn(this.Handle,m_rgn,true);
}