开发者

Creating a Round Edged form in C#

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));
    }

Ive got this Code from Stack Overflow but, this does not produce a clear edged window and moreover the minimize, maximize buttons are not displayed properly. Please Correct the Co开发者_开发百科de. Is there any library(dll) to do the job in C#.


You can find interesting discussion here http://bytes.com/topic/c-sharp/answers/256570-how-do-i-create-windows-forms-rounded-corners.

Or if you have not sizable forms you can use an easy trick like here http://msdn.microsoft.com/en-us/beginner/cc963986.aspx.

But doing It well in WindowsForms is really hard. So if it can be an option to you, I would strongly suggest to use WPF instead. Especially I see you concern about not perfect rendering.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜