469,612 Members | 1,657 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

Rectangle with rounded corners

Hi,

VB.Net, Visual Studio 2003, Windows Application

I want to avoid the old Windows rectangle shape, but I don't need or want
complex bitmaps. What's the easiest way to create a form with rounded
corners please?

I'd would rather not use a bitmap and transparency as I've read in MSDN that
this isn't reliable on video cards with high color resolution. The other way
of using a graphics path and region looks better, but I simply can't seem to
get the AddArcs drawing method working well to create the corners.

Code to just create the arcs for the 4 corners would be magic.

many thanks,
--

Rod Gill

Nov 21 '05 #1
3 11801
"Rod Gill" <rod AT project-systems DOT co DOT nz> schrieb:
I want to avoid the old Windows rectangle shape, but I don't need or want
complex bitmaps. What's the easiest way to create a form with rounded
corners please?

I'd would rather not use a bitmap and transparency as I've read in MSDN
that this isn't reliable on video cards with high color resolution. The
other way of using a graphics path and region looks better, but I simply
can't seem to get the AddArcs drawing method working well to create the
corners.


\\\
Me.FormBorderStyle = FormBorderStyle.None
Me.Height = 300
Me.Width = 400
Dim p As New GraphicsPath()
p.StartFigure()
p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
p.AddLine(40, 0, Me.Width - 40, 0)
p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, 40), 0, 90)
p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
p.CloseFigure()
Me.Region = New Region(p)
Me.BackColor = Color.Red
p.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Hah,

You're a scholar, a gentleman and a good judge of whiskey!

Many thanks

--

Rod Gill
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
"Rod Gill" <rod AT project-systems DOT co DOT nz> schrieb:
I want to avoid the old Windows rectangle shape, but I don't need or want
complex bitmaps. What's the easiest way to create a form with rounded
corners please?

I'd would rather not use a bitmap and transparency as I've read in MSDN
that this isn't reliable on video cards with high color resolution. The
other way of using a graphics path and region looks better, but I simply
can't seem to get the AddArcs drawing method working well to create the
corners.


\\\
Me.FormBorderStyle = FormBorderStyle.None
Me.Height = 300
Me.Width = 400
Dim p As New GraphicsPath()
p.StartFigure()
p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
p.AddLine(40, 0, Me.Width - 40, 0)
p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, 40), 0, 90)
p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
p.CloseFigure()
Me.Region = New Region(p)
Me.BackColor = Color.Red
p.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Remember to add Reference to System.Drawing and add
Imports System.Drawing.Drawing2D to form

Joe Marino

Herfried K. Wagner [MVP] wrote:
"Rod Gill" <rod AT project-systems DOT co DOT nz> schrieb:
I want to avoid the old Windows rectangle shape, but I don't need or
want complex bitmaps. What's the easiest way to create a form with
rounded corners please?

I'd would rather not use a bitmap and transparency as I've read in
MSDN that this isn't reliable on video cards with high color
resolution. The other way of using a graphics path and region looks
better, but I simply can't seem to get the AddArcs drawing method
working well to create the corners.

\\\
Me.FormBorderStyle = FormBorderStyle.None
Me.Height = 300
Me.Width = 400
Dim p As New GraphicsPath()
p.StartFigure()
p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
p.AddLine(40, 0, Me.Width - 40, 0)
p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, 40), 0, 90)
p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
p.CloseFigure()
Me.Region = New Region(p)
Me.BackColor = Color.Red
p.Dispose()
///

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Mel | last post: by
3 posts views Thread by Alberto | last post: by
2 posts views Thread by Konrad | last post: by
1 post views Thread by Carlo, MCP | last post: by
7 posts views Thread by Mark Ingram | last post: by
8 posts views Thread by TheCornjerker | last post: by
6 posts views Thread by Schraalhans Keukenmeester | last post: by
4 posts views Thread by PWS | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.