Make a form with rounded corners

wade

New member
Joined
Sep 28, 2006
Messages
2
Programming Experience
1-3
I am trying to draw a form with four rounded corners. Currently I am trying to do this using the region object, but the corners look rough. Is there a better way to draw the corners and not have them look rough? Using a background image was an idea, but when I resized the form the image became distorted. Thanks.

Code I am currently using:

PublicFunction DrawRoundRect(ByVal g As Graphics, ByVal p As Pen, ByVal x AsSingle, ByVal y AsSingle, ByVal width AsSingle, ByVal height AsSingle, ByVal radius AsSingle) As Region
Dim gp As GraphicsPath = New GraphicsPath
gp.StartFigure()
gp.AddLine(x + radius, y, x + width - (radius * 2), y)
gp.AddArc(x + width - ((radius * 2) + 1), y, radius * 2, radius * 2, 270, 90)
gp.AddLine(x + width - 1, y + radius, x + width - 1, y + height - (radius * 2))
gp.AddArc(x + width - ((radius * 2) + 1), y + height - ((radius * 2) + 1), radius * 2, radius * 2, 0, 90)
gp.AddLine(x + width - (radius * 2), y + height - 1, x + radius, y + height - 1)
gp.AddArc(x, y + height - ((radius * 2) + 1), radius * 2, radius * 2, 90, 90)
gp.AddLine(x, y + height - (radius * 2), x, y + radius)
gp.AddArc(x, y, radius * 2, radius * 2, 180, 90)
gp.CloseFigure()
Dim lvRegion AsNew Region(gp)
Return lvRegion
EndFunction
 
Back
Top