[转]c# winform 绘制圆角窗体

<p>本文转自:<font><a href="http://blog.csdn.net/terry001/archive/2008/05/01/2352511.aspx" target="_blank">http://blog.csdn.net/terry001/archive/2008/05/01/2352511.aspx</a></font></p><p>public void setwindowregion() <br> { <br> system.drawing.drawing2d.graphicspath formpath; <br> formpath = new system.drawing.drawing2d.graphicspath(); <br> rectangle rect=new rectangle(0,22,this.width,this.height-22);//this.left-10,this.top-10,this.width-10,this.height-10); <br> formpath = getroundedrectpath(rect, 30); <br> this.region = new region(formpath); <br> } <br> private graphicspath getroundedrectpath(rectangle rect, int radius) <br> { <br> int diameter = radius; <br> rectangle arcrect = new rectangle(rect.location, new size(diameter, diameter)); <br> graphicspath path = new graphicspath(); <br> // 左上角 <br> path.addarc(arcrect, 180, 90); <br> // 右上角 <br> arcrect.x = rect.right - diameter; <br> path.addarc(arcrect, 270, 90); <br> // 右下角 <br> arcrect.y = rect.bottom - diameter; <br> path.addarc(arcrect, 0, 90); <br> // 左下角 <br> arcrect.x = rect.left; <br> path.addarc(arcrect, 90, 90); <br> path.closefigure(); <br> return path; <br> } <br> protected override void onresize(system.eventargs e) <br> { <br> this.region = null; <br> setwindowregion(); <br> }</p>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值