开发者

Creating a Round Edged form in C#

开发者 https://www.devze.com 2023-04-06 22:45 出处:网络
private static extern IntPtr CreateRoundRectRgn ( int nLeftRect, // x-coordinate of upper-left corner int nTopRect, // y-coordinate of upper-left corner
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

精彩评论

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