//省略几个默认命名空间
using System.Runtime.InteropServices;
^^^^^^^^^^^^^
private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
static void Main()
{
Application.Run(new Form1());
}
[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;
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);
}
}
}