percent color / gauge component

Posted on 2000-04-20
Last Modified: 2010-04-04
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.


PS sorry for my poor English.
Question by:ka1a
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

TheNeil earned 10 total points
ID: 2734542
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);
  S: string;
  X, Y: Integer;
  OverRect: TBltBitmap;
  OverRect := TBltBitmap.Create;
    S := Format('%d%%', [PercentDone]);
    with OverRect.Canvas do
      Brush.Style := bsClear;
      Font := Self.Font;
      with PaintRect do
        X := (Right - Left + 1 - TextWidth(S)) div 2;
        Y := (Bottom - Top + 1 - TextHeight(S)) div 2;
      TextRect(PaintRect, X, Y, S);
    AnImage.Canvas.Draw(0, 0, OverRect);

The Neil =:)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question