如果您只是想將圓角修剪出來,可以在窗體中重寫OnPaint,並使用所需的窗口形狀創建一個路徑(System.Drawing.Drawing2D.GraphicsPath),並將該路徑指定給窗體的Region屬性。這有點笨重,但它可以做你想做的事。例如,對於統一的彎角你可以做(vb,不是C#,對不起):
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim r As Rectangle = Me.ClientRectangle
Dim w As Integer = 50 'width of curvature
Dim h As Integer = 50 'heigth of curvature
Dim gp As New System.Drawing.Drawing2D.GraphicsPath
gp.StartFigure()
gp.AddArc(r.Right - w, r.Top, w, h, 270, 90)
gp.AddArc(r.Right - w, r.Bottom - h, w, h, 0, 90)
gp.AddArc(r.Left, r.Bottom - h, w, h, 90, 90)
gp.AddArc(r.Left, r.Top, w, h, 180, 90)
gp.CloseFigure()
e.Graphics.DrawPath(Pens.Black, gp)
Me.Region = New System.Drawing.Region(gp)
End Sub
您是否嘗試過微軟提出的修補程序? – dowhilefor 2012-01-09 15:17:24
3)打敗你的客戶?或者他們的展示區域是否有圓角? – 2012-01-09 15:17:55
@dowhilefor是的,我試過修補程序,它不一致。這也不是我們希望客戶必須做的事情。 – kmarks2 2012-01-09 15:18:52