Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing.Drawing2D
- Imports System.Runtime.InteropServices
- Public Class RoundedForm
- Inherits Form
- <DllImport("Gdi32.dll", EntryPoint:="CreateRoundRectRgn")>
- Private Shared Function CreateRoundRectRgn(ByVal nLeftRect As Integer, ByVal nTopRect As Integer, ByVal nRightRect As Integer, ByVal nBottomRect As Integer, ByVal nWidthEllipse As Integer, ByVal nHeightEllipse As Integer) As IntPtr
- End Function
- Private _angle As Single = 400.0F
- Public Property Angle As Single
- Get
- Return _angle
- End Get
- Set(value As Single)
- _angle = value
- Invalidate()
- End Set
- End Property
- Public Property Alpha As Integer = 255
- Public Property BackColor2 As Color = BackColor
- Public Property BackColor3 As Color = BackColor
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim g As Graphics = e.Graphics
- g.SmoothingMode = SmoothingMode.AntiAlias
- Dim brush As New LinearGradientBrush(New Point(Me.Width / 2, 0), New Point(Me.Width / 2, Me.Height), Color.FromArgb(Alpha, BackColor3), Color.FromArgb(Alpha, BackColor2))
- g.FillRectangle(brush, ClientRectangle)
- Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, _angle, _angle))
- MyBase.OnPaint(e)
- End Sub
- Protected Overrides Sub OnResize(eventargs As EventArgs)
- MyBase.OnResize(eventargs)
- Invalidate()
- End Sub
- Public Sub New()
- SetStyle(ControlStyles.SupportsTransparentBackColor, True)
- SetStyle(ControlStyles.UserPaint, True)
- DoubleBuffered = True
- FormBorderStyle = BorderStyle.None
- StartPosition = FormStartPosition.CenterScreen
- MaximizeBox = False
- MinimizeBox = False
- ShowInTaskbar = False
- ShowIcon = False
- Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, _angle, _angle))
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement