• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 554
  • Last Modified:

percent color / gauge component

Is it possible to choose the color of the percent (%) that make the progress visible.  When you change the back- and forground color of the gaugecomponent, the color of the percent-message will change automaticly (ex. progress=black, percent=white / progress=navy, percent=yellow).  I tried with the fontcolor, no change.

All info welcome.

Dirk.

PS sorry for my poor English.
0
ka1a
Asked:
ka1a
1 Solution
 
TheNeilCommented:
What you need to do is open up the gauges.pas file in the Source\Samples directory. Look for where it uses cmSrcInvert. It's at these points that it's adding the text and it's here that you need to modify the code to draw the text in way that you want. The most flexible way would be to use the font proprty of the component so (for example) PaintAsText routine would become:

procedure TGauge.PaintAsText(AnImage: TBitmap; PaintRect: TRect);
var
  S: string;
  X, Y: Integer;
  OverRect: TBltBitmap;
begin
  OverRect := TBltBitmap.Create;
  try
    OverRect.MakeLike(AnImage);
    PaintBackground(OverRect);
    S := Format('%d%%', [PercentDone]);
    with OverRect.Canvas do
    begin
      Brush.Style := bsClear;
      Font := Self.Font;
      with PaintRect do
      begin
        X := (Right - Left + 1 - TextWidth(S)) div 2;
        Y := (Bottom - Top + 1 - TextHeight(S)) div 2;
      end;
      TextRect(PaintRect, X, Y, S);
    end;
    AnImage.Canvas.Draw(0, 0, OverRect);
  finally
    OverRect.Free;
  end;
end;

The Neil =:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now