首页  编辑  

改变ProgressBar的颜色

Tags: /超级猛料/VCL/状态栏和进度条/   Date Created:

改变ProgressBar的颜色?

change the color of a TProgressbar ?

uses

 CommCtrl;

procedure TForm1.Button1Click(Sender: TObject);

begin

 // 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);

begin

 SetWindowLong(ProgressBar1.Handle, GWL_STYLE,

   GetWindowLong(ProgressBar1.Handle, GWL_STYLE) or PBS_MARQUEE);

end;

//------------------------------------------------------------------------------

procedure TForm1.Button1Click(Sender: TObject);

var

 i: Integer;

begin

 for i := 0 to 30 do

 begin

   Sleep(100);

   ProgressBar1.StepIt;

   Application.ProcessMessages;

 end;

end;

img_4740.bmp (40.2KB)