本来以为你搞定了.pCanvas是panel上的一个paintbox.canvas
procedure TFrmMain.PanelGr(InitializeColor, TerminalColor: TColor;panel:Tpanel;pCanvas:TCanvas); //panel背景渐变
var
ARect : TRect;
FillNumber,i:integer;
RED,Green,Blue:integer;
begin
for FillNumber := 0 to panel.Height-1 do
begin
Red := GetRvalue(InitializeColor) + Trunc(FillNumber * (GetRvalue(TerminalColor) - GetRvalue(InitializeColor)) / (panel.Height - 1));
Green := GetGvalue(InitializeColor) + Trunc(FillNumber * (GetGvalue(TerminalColor) - GetGvalue(InitializeColor)) /(panel.Height - 1));
Blue := GetBvalue(InitializeColor) + Trunc(FillNumber * (GetBvalue(TerminalColor) - GetBvalue(InitializeColor)) / (panel.Height - 1));
pCanvas.Pen.Color := RGB(Red, Green, Blue);
pCanvas.MoveTo(0, FillNumber);
pCanvas.LineTo(panel.Width, FillNumber);
end;
end;
这是我写的函数,自己改改就可以用了