방법: 모양을 가진 Windows Form 만들기

업데이트: 2007년 11월

이 예제에서는 폼을 기초로 크기가 조정되는 타원 모양의 폼을 만듭니다.

예제

 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
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:
    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);
    }

코드 컴파일

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

이 예제에서는 OnPaint 메서드를 재정의하여 폼의 모양을 변경합니다. 이 코드를 사용하려면 메서드 선언과 그리기 코드를 메서드 안에 복사해야 합니다.

참고 항목

참조

OnPaint

Region

System.Drawing

AddEllipse

Region

기타 리소스

그래픽 프로그래밍 시작