I have a code that helped me make a rounded corner, border-less WinForm
. It works fine but the thing is that it has no borders, so I want to add rounded borders to it. Also, I only want TopLeft
and BottomRight
corners to be rounded.
This is my current code:
public partial class mainForm : Form
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
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();
this.FormBorderStyle = FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
}
It is easily achievable in WPF
but how do I get that in WinForms
?
What should I do?