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得到了这段代码,但是,这不会产生清晰的边缘窗口,而且最小化、最大化按钮也不能正确显示。请更正代码。在C#中有没有库(Dll)来做这项工作。
发布于 2011-09-24 15:42:41
你可以在这里找到有趣的讨论http://bytes.com/topic/c-sharp/answers/256570-how-do-i-create-windows-forms-rounded-corners。
或者,如果你没有很大的表单,你可以使用一个简单的技巧,比如这里的http://msdn.microsoft.com/en-us/beginner/cc963986.aspx。
但在WindowsForms中做好这件事真的很难。因此,如果您可以选择WPF,我强烈建议您使用WPF。我特别注意到你对不完美的渲染的担忧。
https://stackoverflow.com/questions/7537579
复制相似问题