Jump to content
Rrodd

Problem with Gauge component.

Recommended Posts

Hello, I have a problem with the component Gauge, looks like it draws the text twice, one white and another with the inverted color (this is the only I want to be drawn), looking bad.

I am using a "Windows VCL Application - Delphi" under Delphi 10.4.

I'd like to know what to do for this to work like expected, or another free gauge alternative and similar component.

I have sent a snapshot of the problem.

 

Thanks.

gauge01.bmp

Share this post


Link to post
9 hours ago, Rrodd said:

Hello, I have a problem with the component Gauge, looks like it draws the text twice, one white and another with the inverted color (this is the only I want to be drawn), looking bad.

I am using a "Windows VCL Application - Delphi" under Delphi 10.4.

I'd like to know what to do for this to work like expected, or another free gauge alternative and similar component.

I have sent a snapshot of the problem.

 

Thanks.

gauge01.bmp

TGauge is a really ancient sample component (from D1 days I think). Have you looked at TProgressbar as alternative?

Share this post


Link to post

Hi, TProgressbar has a graphical animation and does not add a percent, and I don't know how to have this features with it, and remove the animation.

 

Share this post


Link to post

The Bonus KSVC components included with Delphi but not installed by default include some components that might help. Installable through GetIt.

 

Going through a few it seems the Meter component from the KSVC components can come closest.  The KSVC progress bar makes the text match the bar or background color depending on the progress which makes the yellow bar / white background combination a problem. Also here I don't see the messed up text for the ancient TGauge. 

 

ProgressBars.png

Edited by Brian Evans

Share this post


Link to post
11 hours ago, Rrodd said:

one white and another with the inverted color (this is the only I want to be drawn), looking bad.

 

Overdraw the control.    Here's two workarounds. The second uses the centering text of Panel.caption. 

 

 

procedure ComputeBarCenter(control: TControl; var x, y : Integer);
begin
  with Control do begin
    x := Left + width div 2;
    y := Top + Height div 2;
  end;
  //self.Left := 10;
end;


procedure TForm9.Button1Click(Sender: TObject);
var
  textX, textY: Integer;
begin
  gauge1.ShowText := False;
  computeBarcenter(gauge1, textX, textY);
  self.Canvas.TextOut(textX-5,textY-3,'50%');
end;

procedure PutlabelControlAroundGraphic(panel, graphic: TControl);
begin
  with graphic do
  panel.SetBounds(Left-3, Top-3, Width+3, Height+3);
end;

procedure TForm9.Button2Click(Sender: TObject);
begin
  Gauge2.ShowText := False;
  panel1.Caption := 'Working hard Boss';
  PutLabelControlAroundGraphic(panel1, Gauge2);
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×