RAD Studio VCL Reference
|
Determines the color and pattern for filling graphical shapes and backgrounds.
property Brush: TBrush;
__property TBrush Brush;
Set the Brush property to specify the color and pattern to use when drawing the background or filling in graphical shapes. The value of Brush is a TBrush object. Set the properties of the TBrush object to specify the color and pattern or bitmap to use when filling in spaces on the canvas.
C++ Examples:
/* The following code loads a bitmap from a file and assigns it to the Brush of the Canvas of Form1: */ #include <memory> //for STL auto_ptr class void __fastcall TForm1::Button1Click(TObject *Sender) { std::auto_ptr<Graphics::TBitmap> BrushBmp(new Graphics::TBitmap); BrushBmp->LoadFromFile("../bm1.BMP"); Form1->Canvas->Brush->Bitmap = BrushBmp.get(); Form1->Canvas->FillRect(Rect(0,0,100,100)); Form1->Canvas->Brush->Bitmap = NULL; }
Delphi Examples:
{ The following code loads a bitmap from a file and assigns it to the Brush of the Canvas of Form1: } var Bitmap: TBitmap; procedure TForm1.Button1Click(Sender: TObject); begin Bitmap := TBitmap.Create; try Bitmap.LoadFromFile('bm1.BMP'); Form1.Canvas.Brush.Bitmap := Bitmap; Form1.Canvas.FillRect(Rect(0,0,100,100)); finally Form1.Canvas.Brush.Bitmap := nil; Bitmap.Free; end; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|