Advertisement
Asfelius

Simple Round Corners

Sep 16th, 2023
1,437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VisualBasic 1.00 KB | Source Code | 0 0
  1. Public Class Form1
  2.  
  3.     Private Sub roundCorners(obj As Form)
  4.  
  5.         obj.FormBorderStyle = FormBorderStyle.None
  6.         obj.BackColor = Color.Cyan
  7.  
  8.  
  9.         Dim DGP As New Drawing2D.GraphicsPath
  10.         DGP.StartFigure()
  11.         'top left corner
  12.        DGP.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
  13.         DGP.AddLine(40, 0, obj.Width - 40, 0)
  14.  
  15.         'top right corner
  16.        DGP.AddArc(New Rectangle(obj.Width - 40, 0, 40, 40), -90, 90)
  17.         DGP.AddLine(obj.Width, 40, obj.Width, obj.Height - 40)
  18.  
  19.         'buttom right corner
  20.        DGP.AddArc(New Rectangle(obj.Width - 40, obj.Height - 40, 40, 40), 0, 90)
  21.         DGP.AddLine(obj.Width - 40, obj.Height, 40, obj.Height)
  22.  
  23.         'buttom left corner
  24.        DGP.AddArc(New Rectangle(0, obj.Height - 40, 40, 40), 90, 90)
  25.         DGP.CloseFigure()
  26.  
  27.         obj.Region = New Region(DGP)
  28.  
  29.  
  30.     End Sub
  31.  
  32.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  33.         roundCorners(Me)
  34.     End Sub
  35. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement