Nasıl yapılır: Şekilli Windows Formu Oluşturma

Bu örnek, forma formla birlikte yeniden boyutlandıran eliptik bir şekil verir.

Örnek

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

Kod Derleniyor

Bu örnek şunları gerektirir:

Bu örnek, formun OnPaint şeklini değiştirmek için yöntemini geçersiz kılar. Bu kodu kullanmak için yöntem bildirimini ve yöntemin içindeki çizim kodunu kopyalayın.

Ayrıca bkz.