2011-03-17 94 views

回答

1

幾年後......但這可能是你的問題的答案。

Public Sub DrawRoundedRectangle(ByVal objGraphics As Graphics, _ 
           ByVal m_intxAxis As Integer, _ 
           ByVal m_intyAxis As Integer, _ 
           ByVal m_intWidth As Integer, _ 
           ByVal m_intHeight As Integer, _ 
           ByVal m_diameter As Integer) 



    'Dim g As Graphics 
    Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, 
            m_intHeight) 
    Dim ArcRect As New RectangleF(BaseRect.Location, 
           New SizeF(m_diameter, m_diameter)) 
    'top left Arc 
    objGraphics.DrawArc(Pens.Black, ArcRect, 180, 90) 
    objGraphics.DrawLine(Pens.Black, m_intxAxis + CInt(m_diameter/2), 
         m_intyAxis, 
         m_intxAxis + m_intWidth - CInt(m_diameter/2), 
         m_intyAxis) 

    ' top right arc 
    ArcRect.X = BaseRect.Right - m_diameter 
    objGraphics.DrawArc(Pens.Black, ArcRect, 270, 90) 
    objGraphics.DrawLine(Pens.Black, m_intxAxis + m_intWidth, 
         m_intyAxis + CInt(m_diameter/2), 
         m_intxAxis + m_intWidth, 
         m_intyAxis + m_intHeight - CInt(m_diameter/2)) 

    ' bottom right arc 
    ArcRect.Y = BaseRect.Bottom - m_diameter 
    objGraphics.DrawArc(Pens.Black, ArcRect, 0, 90) 
    objGraphics.DrawLine(Pens.Black, m_intxAxis + CInt(m_diameter/2), 
         m_intyAxis + m_intHeight, 
         m_intxAxis + m_intWidth - CInt(m_diameter/2), 
         m_intyAxis + m_intHeight) 

    ' bottom left arc 
    ArcRect.X = BaseRect.Left 
    objGraphics.DrawArc(Pens.Black, ArcRect, 90, 90) 
    objGraphics.DrawLine(Pens.Black, 
         m_intxAxis, m_intyAxis + CInt(m_diameter/2), 
         m_intxAxis, 
         m_intyAxis + m_intHeight - CInt(m_diameter/2)) 

End Sub 

從您的代碼中提供參數來繪製矩形,然後離開您!

+0

哦好多了!非常感謝!一個更好的答案總是被接受的,無論多少年後它可能會遲到。 ;) – FreeSnow