how can I create smooth corner rounded form in vb .net
I have no idea how I can do this.
In the image above, this has been done, but as you can see, it is pixelated.
Try this , smoother corners
Private borderForm As New Form
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With Me
.FormBorderStyle = Windows.Forms.FormBorderStyle.None
.Region = New Region(RoundedRectangle(.ClientRectangle, 50))
End With
With borderForm
.ShowInTaskbar = False
.FormBorderStyle = Windows.Forms.FormBorderStyle.None
.StartPosition = FormStartPosition.Manual
.BackColor = Color.Black
.Opacity = 0.25
Dim r As Rectangle = Me.Bounds
r.Inflate(2, 2)
.Bounds = r
.Region = New Region(RoundedRectangle(.ClientRectangle, 50))
r = New Rectangle(3, 3, Me.Width - 4, Me.Height - 4)
.Region.Exclude(RoundedRectangle(r, 48))
.Show(Me)
End With
End Sub
Private Function RoundedRectangle(rect As RectangleF, diam As Single) As Drawing2D.GraphicsPath
Dim path As New Drawing2D.GraphicsPath
path.AddArc(rect.Left, rect.Top, diam, diam, 180, 90)
path.AddArc(rect.Right - diam, rect.Top, diam, diam, 270, 90)
path.AddArc(rect.Right - diam, rect.Bottom - diam, diam, diam, 0, 90)
path.AddArc(rect.Left, rect.Bottom - diam, diam, diam, 90, 90)
path.CloseFigure()
Return path
End Function
Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Dim r As New Rectangle(1, 1, Me.Width - 2, Me.Height - 2)
Dim path As Drawing2D.GraphicsPath = RoundedRectangle(r, 48)
Using pn As New Pen(Color.Black, 2)
e.Graphics.DrawPath(pn, path)
End Using
End Sub