Hai all,
I have a normal win form.I want that form to have shape with ellipsed corner on all four sides with enlarged size.
Can anyone of u plz tell me that how to do this?
Printable View
Hai all,
I have a normal win form.I want that form to have shape with ellipsed corner on all four sides with enlarged size.
Can anyone of u plz tell me that how to do this?
this will shape your form
Code:me.region = RoundedRec(10,10,200,100)
Code:Private Function RoundedRec(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer) As System.Drawing.Drawing2D.GraphicsPath
' Make and Draw a path.
Dim graphics_path As New System.Drawing.Drawing2D.GraphicsPath
graphics_path.AddLine(X + 10, Y, X + Width, Y) 'add the Top line to the path
'Top Right corner
Dim tr() As Point = { _
New Point(X + Width, Y), _
New Point((X + Width) + 4, Y + 2), _
New Point((X + Width) + 8, Y + 6), _
New Point((X + Width) + 10, Y + 10)}
graphics_path.AddCurve(tr) 'Add the Top right curve to the path
'Bottom right corner
Dim br() As Point = { _
New Point((X + Width) + 10, Y + Height), _
New Point((X + Width) + 8, (Y + Height) + 4), _
New Point((X + Width) + 4, (Y + Height) + 8), _
New Point(X + Width, (Y + Height) + 10)}
graphics_path.AddCurve(br) 'Add the Bottom right curve to the path
'Bottom left corner
Dim bl() As Point = { _
New Point(X + 10, (Y + Height) + 10), _
New Point(X + 6, (Y + Height) + 8), _
New Point(X + 2, (Y + Height) + 4), _
New Point(X, Y + Height)}
graphics_path.AddCurve(bl) 'Add the Bottom left curve to the path
'Top left corner
Dim tl() As Point = { _
New Point(X, Y + 10), _
New Point(X + 2, Y + 6), _
New Point(X + 6, Y + 2), _
New Point(X + 10, Y)}
graphics_path.AddCurve(tl) 'add the Top left curve to the path
Return graphics_path
End Function
This line
Should be thisCode:me.region = RoundedRec(10,10,200,100)
Code:m.region = New System.Drawing.Region(RoundedRec(10, 10, 200, 100))
my mistake. stanavs right
Hai paul,
Thank u very much for ur help..I have tried ur code..I have got the shaped form with curve edges...But the only thing is I couldnt get the smooth curve..b'coz some projections are coming in the curve on all four sides...is there any way to reduce that projections and to make the curve to be smooth in ur code???
you could try setting the smoothing mode...
e.graphics.smoothingMode = SmoothingMode.AntiAliased