Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simply round corners of a form

2 views
Skip to first unread message

Mike D

unread,
Nov 20, 2003, 11:49:23 AM11/20/03
to
I am looking for a way in vb.net to take a form with sharp corners and just
round off the corners a bit so they arent so sharp.

I have seen this done in other applications.


One Handed Man

unread,
Nov 20, 2003, 1:13:38 PM11/20/03
to
Put a panel on the form and then make the form tranparent. You can add the
controls over the panel.

OHM

Herfried K. Wagner [MVP]

unread,
Nov 20, 2003, 1:29:22 PM11/20/03
to
* "Mike D" <dib...@hotmail.com> scripsit:

> I am looking for a way in vb.net to take a form with sharp corners and just
> round off the corners a bit so they arent so sharp.
>
> I have seen this done in other applications.

Quick and dirty:

\\\
Me.FormBorderStyle = FormBorderStyle.None
Me.Height = 300
Me.Width = 400
Dim p As New Drawing2D.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
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

One Handed Man

unread,
Nov 20, 2003, 1:41:35 PM11/20/03
to
Forget my post, it was untested and simply incorrect.

Sorry - OHM

Mike D

unread,
Nov 20, 2003, 2:51:09 PM11/20/03
to
WOW. I was thinking that there was something quick and simple. But I highly
appreciate the technical approach, Realizing that all things dont come in
quick and dirty flavors
"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:bpj174$1pdf3q$2...@ID-208219.news.uni-berlin.de...

Mike D

unread,
Nov 20, 2003, 2:52:27 PM11/20/03
to
What does the 'P' reffence? I am doing this in vb.net if that helps any?

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:bpj174$1pdf3q$2...@ID-208219.news.uni-berlin.de...

Mike D

unread,
Nov 20, 2003, 2:54:10 PM11/20/03
to
froget my last post asking what the 'P' reffrenced. I was trying to first
create a module that I could access from all my forms, However it all
errored out. I placed the code in the form load event and all worked fine.

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:bpj174$1pdf3q$2...@ID-208219.news.uni-berlin.de...

William Ryan

unread,
Nov 20, 2003, 3:06:25 PM11/20/03
to
Nice post - neither quick nor dirty but definitely way cool.

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:bpj174$1pdf3q$2...@ID-208219.news.uni-berlin.de...

Mike D

unread,
Nov 20, 2003, 3:05:14 PM11/20/03
to
This works but does'nt. If I resize my form. I lose the formatiing. Is there
no way for me to keep the rounded corners when resizing?
"Mike D" <dib...@hotmail.com> wrote in message
news:%234lKCZ4...@TK2MSFTNGP10.phx.gbl...

Bernie Yaeger

unread,
Nov 20, 2003, 3:12:04 PM11/20/03
to
Hi Mike,

Try this:
Me.FormBorderStyle = FormBorderStyle.None

' this would make the form purely the designated color, without

' the control or windowstate menus and without a caption, drag top, icon,
etc.

Me.Height = 688

Me.Width = 360

Dim p As New Drawing2D.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.Thistle

HTH,

Bernie Yaeger

"Mike D" <dib...@hotmail.com> wrote in message
news:%234lKCZ4...@TK2MSFTNGP10.phx.gbl...

Mike D

unread,
Nov 20, 2003, 3:20:44 PM11/20/03
to
NOPE. Sorry but thanks anyways.

See, What I am trying to do is to keep the Border. Both examples have had
me turn it off. What I really would like to accomplish is to give users an
easier flowing lookng solution instead of all squared corners.

Something that can resized and still keep it's corners.
"Bernie Yaeger" <ber...@cherwellinc.com> wrote in message
news:e0zcRK6r...@TK2MSFTNGP11.phx.gbl...

Herfried K. Wagner [MVP]

unread,
Nov 20, 2003, 3:31:08 PM11/20/03
to
* "Mike D" <dib...@hotmail.com> scripsit:
> This works but does'nt. If I resize my form. I lose the formatiing. Is there
> no way for me to keep the rounded corners when resizing?

You will have to create a new region as shown in the sample with
appropriate size and reassign it to the form's 'Region' property.

Herfried K. Wagner [MVP]

unread,
Nov 20, 2003, 3:30:25 PM11/20/03
to
* "Bernie Yaeger" <ber...@cherwellinc.com> scripsit:
[...]

I remember I saw the code somewhere...

Herfried K. Wagner [MVP]

unread,
Nov 20, 2003, 3:29:18 PM11/20/03
to
* "Mike D" <dib...@hotmail.com> scripsit:
> WOW. I was thinking that there was something quick and simple. But I highly
> appreciate the technical approach, Realizing that all things dont come in
> quick and dirty flavors

The solution only shows one way to create the irregularly shaped form.
You can archieve similar appearance by specifying the form's
'TransparenceKey' property (but I like setting the 'Region' more).

Chris Dunaway

unread,
Nov 20, 2003, 5:56:53 PM11/20/03
to
On Thu, 20 Nov 2003 15:20:44 -0500, Mike D wrote:

> NOPE. Sorry but thanks anyways.
>
> See, What I am trying to do is to keep the Border. Both examples have had

What you'll probably have to do is draw the border in the forms Paint
event. I have done that with a circular form. After assigning a circular
region, in the paint event, I had to manually draw the border.

If you need the form to be resizable, then when the forms size changes,
you'll have to recalcuate the region. The paint event should handle
drawing the border and caption.

Try asking in the drawing groups for more information as well. I may try
to make a simple example for myself. If it turns out OK, I post it.


--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Bernie Yaeger

unread,
Nov 20, 2003, 7:08:32 PM11/20/03
to
Yep, got it from you. I always pass along good work whenever it appears
appropriate.

Bernie

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message

news:bpj8ae$1orbvv$2...@ID-208219.news.uni-berlin.de...

Herfried K. Wagner [MVP]

unread,
Nov 20, 2003, 8:25:28 PM11/20/03
to
* "Bernie Yaeger" <ber...@cherwellinc.com> scripsit:
> Yep, got it from you. I always pass along good work whenever it appears
> appropriate.

No problem... Thx!

One Handed Man

unread,
Nov 21, 2003, 2:47:37 AM11/21/03
to
Yes, use the DataTable.Clear() method.

OHM

Mike D

unread,
Nov 21, 2003, 7:48:39 AM11/21/03
to
Thank you all. You too Bernie for originating this.

Seems I am over my head yet in this field and will do as asked and resume
in the drawings group. I have read many vb books and always just skip right
over the drawings parts of the books thinking, I do nothing but databases, I
will never need that stuff. LOL. Funny how things come back in time to slap
you in your face when you aren't looking. Should have read those chapeters
on drawing now shouldn't I..


"Bernie Yaeger" <ber...@cherwellinc.com> wrote in message

news:e3w1ZO8r...@TK2MSFTNGP09.phx.gbl...

0 new messages