【发布时间】:2011-11-24 03:41:01
【问题描述】:
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);
public Form1()
{
InitializeComponent();
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0,Width-5, Height - 5, 20, 20));
}
我从 Stack Overflow 获得了这段代码,但这不会产生清晰的边缘窗口,而且最小化、最大化按钮也无法正确显示。请更正代码。是否有任何库(dll)可以在 C# 中完成这项工作。
【问题讨论】:
-
在表单上添加更多按钮并编写代码以关闭、最大化等。
-
你看,表格的边缘在绘制时并不完美,这是主要问题。
-
我同意 Tigra。这在 WPF 中很简单。
标签: c# .net winforms gdi+ rounded-corners