delphi编程修改ProgressBar的颜色
关键代码如下:
uses
CommCtrl;
procedure TForm1.Button1Click(Sender: TObject);
// Set the Background color to teal
Progressbar1.Brush.Color := clTeal;
// Set bar color to yellow
SendMessage(ProgressBar1.Handle, PBM_SETBARCOLOR, 0, clYellow);
end;
WinXP风格进度条
const
{$EXTERNALSYM PBS_MARQUEE}
PBS_MARQUEE = 08;
procedure TForm1.FormCreate(Sender: TObject);
SetWindowLong(ProgressBar1.Handle, GWL_STYLE,
GetWindowLong(ProgressBar1.Handle, GWL_STYLE) or PBS_MARQUEE);
end;
//------------------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
for i := 0 to 30 do
Sleep(100);
ProgressBar1.StepIt;
Application.ProcessMessages;
end;
end;