방법: 단색 브러시 만들기

다음은 도형 채우기를 위해 Graphics 개체에서 사용할 수 있는 SolidBrush 개체를 만드는 예제입니다.

예제

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;
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();
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()

강력한 프로그래밍

사용을 마친 후에는 브러시 개체와 같이 시스템 리소스를 소비하는 개체에 대해 Dispose를 호출해야 합니다.

참고 항목