Share via


方法 : Windows フォームに塗りつぶした楕円を描画する

更新 : 2007 年 11 月

この例は、塗りつぶした楕円をフォームに描画します。

使用例

Dim myBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.FillEllipse(myBrush, New Rectangle(0, 0, 200, 300))
myBrush.Dispose()
formGraphics.Dispose()
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(myBrush, new Rectangle(0, 0, 200, 300));
myBrush.Dispose();
formGraphics.Dispose();
System::Drawing::SolidBrush^ myBrush =
    gcnew System::Drawing::SolidBrush(System::Drawing::Color::Red);
System::Drawing::Graphics^ formGraphics;
formGraphics = this->CreateGraphics();
formGraphics->FillEllipse(myBrush, Rectangle(0, 0, 200, 300));
delete myBrush;
delete formGraphics;

コードのコンパイル方法

Load イベント ハンドラでこのメソッドを呼び出すことはできません。フォームがサイズ変更された場合、または別のフォームによって隠れている場合、描画済みのコンテンツは再描画されません。コンテンツを自動的に再描画するには、OnPaint メソッドをオーバーライドする必要があります。

堅牢性の高いプログラム

システム リソースを消費するオブジェクト (Brush オブジェクトや Graphics オブジェクトなど) では、必ず Dispose を呼び出す必要があります。

参照

その他の技術情報

Windows フォームにおけるグラフィックスと描画

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

アルファ ブレンドの直線と塗りつぶし

ブラシを使用した図形の塗りつぶし