Simply round corners of a form

  • Thread starter Thread starter Mike D
  • Start date Start date
M

Mike D

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.
 
Put a panel on the form and then make the form tranparent. You can add the
controls over the panel.

OHM
 
* "Mike D said:
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
///
 
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
 
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.
 
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?
 
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
 
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.
 
* "Mike D said:
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).
 
* "Mike D said:
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.
 
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.
 
Yep, got it from you. I always pass along good work whenever it appears
appropriate.

Bernie
 
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 said:
Yep, got it from you. I always pass along good work whenever it appears
appropriate.

Bernie

Herfried K. Wagner said:
* "Bernie Yaeger" <[email protected]> scripsit:
[...]

I remember I saw the code somewhere...
 
Back
Top