本例效果图:
SolidBrush:定义单色画笔。画笔用于填充图形形状,如矩形、椭圆、扇形、多边形和封闭路径。
FillRectangle:填充由一对坐标、一个宽度和一个高度指定的矩形的内部
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses GDIPAPI,GDIPOBJ; procedure TForm1.FormPaint(Sender: TObject); var g:TGPGraphics; p:TGPPen; hx:TGPSolidBrush; {定义单色画刷类} rect:TGPRect; {定义一个TGPRECT的结构} begin g:=TGPGraphics.Create(Canvas.Handle); {建立实例} p:=TGPPen.Create(aclRed,2); {建立实例} hx:=TGPSolidBrush.Create(aclYellow); {建立实例} g.Clear(aclWhite); rect:=MakeRect(20,20,200,100); {给结构传递数值} g.DrawRectangle(p,rect); {画一个矩形} g.FillRectangle(hx,rect); {填充这个矩形} hx.Free; //释放实例 p.Free; g.Free; end; end.