简体   繁体   中英

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 Code. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM