次の方法で共有


方法 : 成型された Windows フォームを作成する

更新 : 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

その他の技術情報

グラフィックス プログラミングについて