473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hefried's post on Rounded Corners

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
do********@comcast.nospam.net
www.devbuzz.com
www.knowdotnet.com
Nov 20 '05 #1
10 985
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
------------------
"William Ryan" <do********@nospam.comcast.net> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl...
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
do********@comcast.nospam.net
www.devbuzz.com
www.knowdotnet.com

Nov 20 '05 #2
Thanks Ken!
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uV**************@tk2msftngp13.phx.gbl...
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
------------------
"William Ryan" <do********@nospam.comcast.net> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl...
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
do********@comcast.nospam.net
www.devbuzz.com
www.knowdotnet.com


Nov 20 '05 #3
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote...

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.
Nov 20 '05 #4
I can't get this one to work...

Am I missing something here?

Gary
Nov 20 '05 #5
"William Ryan" <do********@nospam.comcast.net> schrieb im Newsbeitrag
news:OB**************@TK2MSFTNGP09.phx.gbl...
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,


I'm not Herfried, but you might find the answer here:
http://groups.google.com/groups?as_e...*&as_scoring=d
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
Hi,

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

Ken

-----------------------

"Didymus" <di************@hotmail.com> wrote in message
news:Ov**************@TK2MSFTNGP11.phx.gbl...
I can't get this one to work...

Am I missing something here?

Gary

Nov 20 '05 #7
* "Armin Zingler" <az*******@freenet.de> scripsit:
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_e...*&as_scoring=d


;-)

<http://groups.google.com/groups?selm=OT79ZF6rDHA.2028%40TK2MSFTNGP10.phx.gb l>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #8
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 [MVP]" <hi***************@gmx.at> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
* "Armin Zingler" <az*******@freenet.de> scripsit:
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_e...*&as_scoring=d
;-)

<http://groups.google.com/groups?selm...FTNGP10.phx.gb
l>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #9
* "Tom Spink" <thomasdotspinkat@ntlworlddotcom> scripsit:
Just because you have that in your favourites..... ;-)))


I used Google Groups Search to locate the post.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #10
Thanks Ken,

Always the simple solution <grin>

Gary
Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Konrad | last post by:
Hi This is maybe simple question but how to render DataGrid and Tables with rounded corners? Thanks Konrad
1
by: kidelectric | last post by:
The issue I am having is that I would like to be able to drag-and-drop div elements that have rounded corners.* Since these elements will be dynamically created (including background color), I could...
4
by: PWS | last post by:
I am despertely trying get a DIV to look like a box with rounded corners. I can find load of examples this where the first line of text has the top graphic and the last line of text has the...
6
by: moondaddy | last post by:
I need to be able to make polygons with rounded corners. This will be to draw group outlines around shapes in a diagramming tool in wpf. all angles in the polygon will be 90 degrees, but somehow...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.