Hefried's post on Rounded Corners

  • Thread starter Thread starter William Ryan
  • Start date Start date
W

William Ryan

Herfried:

A while back you posted a really cool way to round the corners of a form. I
thought I had it saved, but if you have it handy, would you kindly post it?
TIA,

Bill

--
Cordially,

W.G. Ryan
(e-mail address removed)
www.devbuzz.com
www.knowdotnet.com
 
Hi,

Here is how i do it.
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim gp As GraphicsPath = New GraphicsPath

Dim radius As Single

radius = 25

gp.AddLine(radius, 0, Width - (radius * 2), 0)

gp.AddArc(Width - (radius * 2), 0, radius * 2, radius * 2, 270, 90)

gp.AddLine( Width, radius, Width, Height - (radius * 2))

gp.AddArc(Width - (radius * 2), Height - (radius * 2), radius * 2, radius *
2, 0, 90)

gp.AddLine(Width - (radius * 2), Height, radius, Height)

gp.AddArc(0, Height - (radius * 2), radius * 2, radius * 2, 90, 90)

gp.AddLine(0, Height - (radius * 2), 0, radius)

gp.AddArc(0, 0, radius * 2, radius * 2, 180, 90)



gp.CloseFigure()

Dim regRoundRect As New Region(gp)

Me.Region = regRoundRect

End Sub

Ken
 
Thanks Ken!
Ken Tucker said:
Hi,

Here is how i do it.
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim gp As GraphicsPath = New GraphicsPath

Dim radius As Single

radius = 25

gp.AddLine(radius, 0, Width - (radius * 2), 0)

gp.AddArc(Width - (radius * 2), 0, radius * 2, radius * 2, 270, 90)

gp.AddLine( Width, radius, Width, Height - (radius * 2))

gp.AddArc(Width - (radius * 2), Height - (radius * 2), radius * 2, radius *
2, 0, 90)

gp.AddLine(Width - (radius * 2), Height, radius, Height)

gp.AddArc(0, Height - (radius * 2), radius * 2, radius * 2, 90, 90)

gp.AddLine(0, Height - (radius * 2), 0, radius)

gp.AddArc(0, 0, radius * 2, radius * 2, 180, 90)



gp.CloseFigure()

Dim regRoundRect As New Region(gp)

Me.Region = regRoundRect

End Sub

Ken
 
I can never resist messing with code... one might consider defining diameter
and avoid a number of identical multiplications

Dim radius As Single = 25
Dim diameter As Single = ( radius * 2 )

gp.AddLine(radius, 0, Width - diameter, 0)
gp.AddArc(Width - diameter, 0, diameter, diameter, 270, 90)

etc.
 
I can't get this one to work...

Am I missing something here?

Gary
 
Hi,

The graphicspath is in the system.drawing.drawing2d namespace. Add this
to the top of your file.
Imports System.Drawing.Drawing2D



Ken
 
Just because you have that in your favourites..... ;-)))

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations

Herfried K. Wagner said:
* "Armin Zingler said:
A while back you posted a really cool way to round the corners of a
form. [...]
I'm not Herfried, but you might find the answer here:
http://groups.google.com/groups?as_...ugroup=microsoft.public.dotnet.*&as_scoring=d
<http://groups.google.com/[email protected]
l>
 
* "Tom Spink said:
Just because you have that in your favourites..... ;-)))

I used Google Groups Search to locate the post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Is this NG Still working? 6
Writing in IL 11
Stupid Whidbey Questions 2
Using Params with an IN Statemet...Feedback 5
Voice Recognition 2
Who's a bigger Troll, Bailo or NoSpam? 6
OT: VB.NET Humor 5
MSMQ 6

Back
Top