多边形窗体(C#)

  using System.Drawing; using System; using System.Collections; using System.Windows.Forms; using System.ComponentModel; using System.Data; using System.Runtime.InteropServices; namespace Example006_设计多边形窗体 { public partial class Form1:System.Windows.Forms.Form { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } [DllImport("gdi32")] //创建一个多边形作为窗口的显示区域 private static extern IntPtr CreatePolygonRgn(Point[] lpPoint, int nCount, int nPolyFillMode); //lpPoint:保存多边形顶点坐标的数组 //nCount:构成多边形的点数 //nPolyFillMode:填充方式 [DllImport("user32")] //改变窗体形状 private static extern IntPtr SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw); //hWnd:窗口句柄 //hRgn:显示区域的句柄 //bRedraw:是否重画窗体 private void Form1_Load(object sender, 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,1); SetWindowRgn(this.Handle, m_rgn, true); } } }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值