如何:创建实心画笔

此示例创建一个 SolidBrush 对象,Graphics 对象可以用它来填充形状。

示例

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;

可靠编程

当使用完那些使用系统资源的对象(如 Brush 对象)后,应该对这些对象调用 Dispose

请参见

参考

SolidBrush

Brush

概念

GDI+ 中的画笔和实心形状

其他资源

图形编程入门

使用画笔填充形状