<p>本文转自:<font><a href="http://blog.youkuaiyun.com/terry001/archive/2008/05/01/2352511.aspx" target="_blank">http://blog.youkuaiyun.com/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 绘制圆角窗体
最新推荐文章于 2024-11-28 23:43:16 发布
本文详细介绍了如何使用GraphicsPath和Region类在Windows应用中实现窗口区域的圆角化效果,通过创建自定义的圆角矩形路径,并将其设置为窗口区域,使得窗口边角呈现圆滑过渡,提升用户体验。

2056

被折叠的 条评论
为什么被折叠?



