<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>
[转]c# winform 绘制圆角窗体
最新推荐文章于 2023-09-28 16:41:19 发布