AddArc to round top corners of form1 only left arc works

New to GDI+, when I build the rectangle (form1) and add the first AddArc (leftside): p.AddArc(0, 0, 10, 10, 180, 90) it works,

The second AddArc (RightSide): p.AddArc(Me.Width - 10, 0, Me.Width, 10, -180, 90) produces an angle starting on the top left (close to where the first X was placed) and stretches across to the right and (down maybe 15 pixels at end) it looks like to where the right side X is located.

I think it has something to do with the startAngle I assumed putting the second rectangle on the right side it would start the angle from Me.Width – 10. I’m confused! Any help greatly appreciated

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

p.StartFigure()

p.AddArc(0, 0, 10, 10, 180, 90)

p.AddArc(Me.Width - 10, 0, Me.Width, 10, -180, 90)

'Lines in in clockwise order

'top

p.AddLine(0, 0, Me.Width, 0)

'R Side

p.AddLine(Me.Width, 0, Me.Width, Me.Height)

'bot line

p.AddLine(0, Me.Height, Me.Width, Me.Height)

'L Side

p.AddLine(0, Me.Height, 0, 0)

p.CloseFigure()

Me.Region = New Region(p)



Answer this question

AddArc to round top corners of form1 only left arc works

  • Luke Waters

    p.AddArc(Me.Width - 10, 0, Me.Width, 10, -180, 90)

    try this
    p.AddArc(Me.Width - 10, 0, 10, 10, 90, 90)

  • Jaypee

    Finally got it to work!

    'GDI+ rounding the top corners of the form

    Dim p As New System.Drawing.Drawing2D.GraphicsPath

    Dim tl As New Rectangle(0, 0, 7, 8)

    Dim tr As New Rectangle(Me.Width - 8, 0, 7, 8)

    'Lines in in clockwise order

    p.StartFigure()

    p.AddArc(tl, 180, 90)

    'top

    p.AddLine(0, 0, Me.Width, 0)

    p.AddArc(tr, -90, 90)

    ''R Side

    p.AddLine(Me.Width, 0, Me.Width, Me.Height)

    ''bot line

    p.AddLine(Me.Width, Me.Height, 0, Me.Height)

    ''L Side

    p.AddLine(0, Me.Height, 0, 0)

    p.CloseFigure()

    Me.Region = New Region(p)


  • Balasaheb

    Here are a few links which help you draw rounded-rectangles-

    http://www.eggheadcafe.com/articles/gdi_rounded_corners.asp

    http://www.codeproject.com/useritems/rounded_corners.asp

    Hope this helps


  • AddArc to round top corners of form1 only left arc works