Raith
Raith

Reputation: 871

how to change the colors of TProgressBar (background/progressbar itself) to a (custom) color in Delphi?

Original question was about TGauge, however as pointed out in the comments it's not recommended to use, plus any attempts to set the displayed (% text) caption to a custom color would break the inversion (as it's color is just inverted from the background) aka it would not be half colored anymore.

So I am going to use the TProgressBar, but there's still the issue of it's colors (background/progressbar itself) which doesn't seem to have an explicit property to change, it is tied with the current windows theme but there should be a way of ignoring that.

Upvotes: 4

Views: 13169

Answers (1)

No'am Newman
No'am Newman

Reputation: 6477

This doesn't solve the problem for TGauge, but for TProgressBar (and I am aware that there was a strenous argument about another Delphi question yesterday about someone not answering the exact question as posed by the OP, so feel free to ignore). As others have pointed out, TGauge is deprecated and not recommended for use anymore. Here's the code necessary in order to change both the bar and background colour of TProgressBar.

ProgressBar1.Brush.Color:= clRed; // Set Background colour
SendMessage (ProgressBar1.Handle, PBM_SETBARCOLOR, 0, clBlue); // Set bar colour

Upvotes: 4

Related Questions