0

フォーム全体に円を描くにはどうすればよいですか?

私が試したこと:

Dim bmp As New Bitmap(Me.Width, Me.Height)
cWidth = 3
Me.BackgroundImage = Circle (Me.Width, Me.Height,bmp,cWidth)
4

2 に答える 2

1

わかりました、これがです;-)

Public Class Form1
    Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim p As Pen
        Dim d As Integer
        Dim x As Integer

        d = Math.Min(Me.ClientRectangle.Width, Me.ClientRectangle.Height)
        x = Me.ClientRectangle.Width / 2 - d / 2

        p = New Pen(Brushes.Navy, 7)
        e.Graphics.DrawEllipse(p, New Rectangle(x, 0, d, d))
    End Sub

    Private Sub Form1_Resize(sender As System.Object, e As System.EventArgs) Handles MyBase.Resize
        Me.Invalidate()
    End Sub
End Class
于 2012-11-02T00:08:53.087 に答える
1

OnPaint イベント ハンドラをオーバーライドし、そこから実行します。f.ex:

Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
    MyBase.OnPaint(e)

    Dim myPen As New Pen(Color.Red, 3) 'to set width of pen

    e.Graphics.DrawEllipse(myPen, 0, 0, _
                           Me.ClientSize.Width - 1, Me.ClientSize.Height - 1)

    myPen.Dispose()

End Sub
于 2012-11-02T00:00:54.157 に答える