PICTUREBOX ROUND CORNER

  • Thread starter Thread starter ahmeddc
  • Start date Start date
A

ahmeddc

Guest
HI

I used this class
To ROUND CORNER OF PICTUREBOX
But the problem appears poorly when you place a background image

1339765.png

Public Class RoundPictureBox
Inherits PictureBox

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

Dim rect As Rectangle = MyBase.ClientRectangle
Dim g As Graphics = e.Graphics
Dim br As New SolidBrush(MyBase.BackColor)
g.FillRectangle(br, rect)
MyBase.OnPaint(e)

Dim CtrlPen, LightPen, DarkPen As Pen
CtrlPen = SystemPens.ControlDark


LightPen = SystemPens.ControlLightLight
DarkPen = SystemPens.ControlDarkDark

Dim width As Int32 = 12
Dim height As Int32 = 12
Dim x As Int32 = 0
Dim y As Int32 = 0
Dim startAngle As Int32 = 270
Dim sweepAngle As Int32 = -90
g.DrawArc(LightPen, x, y, width, height - 1, startAngle, sweepAngle)

x = rect.Width - width
y = 0
startAngle = 270
sweepAngle = 90
g.DrawArc(CtrlPen, x, y, width - 1, height, startAngle, sweepAngle)

x = rect.Width - width
y = rect.Height - height
startAngle = 0
sweepAngle = 90
g.DrawArc(DarkPen, x, y, width - 1, height - 1, startAngle, sweepAngle)

x = 0
y = rect.Height - height
startAngle = 90
sweepAngle = 90
g.DrawArc(CtrlPen, x, y, width, height - 1, startAngle, sweepAngle)

g.DrawLine(LightPen, (width \ 2) - 1, 0, rect.Right - (width \ 2), 0)
g.DrawLine(DarkPen, rect.Right - 1, (height \ 2), rect.Right - 1, rect.Bottom - (height \ 2) - 1)
g.DrawLine(DarkPen, (width \ 2) - 1, rect.Bottom - 1, rect.Right - (width \ 2), rect.Bottom - 1)
g.DrawLine(LightPen, 0, (height \ 2), 0, rect.Bottom - (height \ 2) - 1)

End Sub

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.Invalidate(MyBase.ClientRectangle)
End Sub
End Class

Continue reading...
 
Back
Top