방법: 도형이 있는 Windows Form 만들기

다음은 양식의 크기를 조정하는 타원형 도형을 제공하는 예제입니다.

예제

protected:
    virtual void OnPaint(
        System::Windows::Forms::PaintEventArgs^ e) override
    {
        System::Drawing::Drawing2D::GraphicsPath^ shape =
            gcnew System::Drawing::Drawing2D::GraphicsPath();
        shape->AddEllipse(0, 0, this->Width, this->Height);
        this->Region = gcnew System::Drawing::Region(shape);
    }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
    System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
    shape.AddEllipse(0, 0, this.Width, this.Height);
    this.Region = new System.Drawing.Region(shape);
}
 Protected Overrides Sub OnPaint( _
ByVal e As System.Windows.Forms.PaintEventArgs)
     Dim shape As New System.Drawing.Drawing2D.GraphicsPath
     shape.AddEllipse(0, 0, Me.Width, Me.Height)
     Me.Region = New System.Drawing.Region(shape)
 End Sub

코드 컴파일

이 예제에는 다음 사항이 필요합니다.

다음은 양식의 모양을 변경하는 OnPaint 메서드를 재정의하는 예제입니다. 이 코드를 사용하려면 메서드 선언과 메서드 내부의 그리기 코드를 복사합니다.

참고 항목