unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, TeCanvas; type TForm1 = class(TForm) ButtonColor1: TButtonColor; ButtonColor2: TButtonColor; ComboBox1: TComboBox; procedure FormCreate(Sender: TObject); procedure FormPaint(Sender: TObject); procedure ButtonColor1Click(Sender: TObject); procedure ButtonColor2Click(Sender: TObject); procedure ComboBox1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses GDIPAPI,GDIPOBJ,TypInfo; procedure TForm1.ButtonColor1Click(Sender: TObject); begin Repaint; end; procedure TForm1.ButtonColor2Click(Sender: TObject); begin Repaint; end; procedure TForm1.ComboBox1Click(Sender: TObject); begin Repaint; end; procedure TForm1.FormCreate(Sender: TObject); var i:Integer; begin for I := 0 to 3 do begin ComboBox1.Items.Add(GetEnumName(TypeInfo(TLinearGradientMode),i)); end; ComboBox1.ItemIndex:=1; ButtonColor1.Caption:='ɫ1 '; ButtonColor2.Caption:='ɫ2 '; ButtonColor1.SymbolColor:=clYellow; ButtonColor2.SymbolColor:=clRed; end; procedure TForm1.FormPaint(Sender: TObject); var g:TGPGraphics; lb:TGPLinearGradientBrush; Rt:TGPRect; c1,c2:TGPColor; begin g:=TGPGraphics.Create(Canvas.Handle); Rt:=MakeRect(60,40,ClientWidth - 120,ClientHeight - 50); c1:=ColorRefToARGB(ButtonColor1.SymbolColor); c2:=ColorRefToARGB(ButtonColor2.SymbolColor); lb:=TGPLinearGradientBrush.Create(Rt,c1,c2,TLinearGradientMode(ComboBox1.ItemIndex)); g.FillEllipse(lb,Rt); lb.Free; g.Free; end; end.