|
-
Oct 19th, 2007, 04:30 AM
#1
Thread Starter
Addicted Member
[2005] How to Shape a winform to our desired shape?
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?
-
Oct 19th, 2007, 12:52 PM
#2
Re: [2005] How to Shape a winform to our desired shape?
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
-
Oct 19th, 2007, 01:02 PM
#3
Re: [2005] How to Shape a winform to our desired shape?
This line
Code:
me.region = RoundedRec(10,10,200,100)
Should be this
Code:
m.region = New System.Drawing.Region(RoundedRec(10, 10, 200, 100))
-
Oct 19th, 2007, 01:03 PM
#4
Re: [2005] How to Shape a winform to our desired shape?
my mistake. stanavs right
-
Oct 23rd, 2007, 12:20 AM
#5
Thread Starter
Addicted Member
Re: [2005] How to Shape a winform to our desired shape?
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???
-
Oct 23rd, 2007, 02:09 AM
#6
Hyperactive Member
Re: [2005] How to Shape a winform to our desired shape?
you could try setting the smoothing mode...
e.graphics.smoothingMode = SmoothingMode.AntiAliased
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|