anchor.diff:        if not (csLoading in ComponentState) then
           raise EInvalidOperation.CreateFmt(SOutOfRange, [-MaxInt, FMaxValue - 1]);
       FMinValue := Value;
  -    if FCurValue < Value then FCurValue := Value;
  -    Refresh;
  -  end;
  -end;
  -
  -procedure TGauge.SetMaxValue(Value: Longint);
  +    if FCurValue < Value then
  +      FCurValue := Value;
  +    Refresh;
  +  end;
  +end;
  +
  +procedure TGauge.SetMaxValue(Value: LongInt);
   begin
     if Value <> FMaxValue then
     begin
  
positive.code:   if FCurValue <> Value then
    begin
      FCurValue := Value;
      if TempPercent <> GetPercentDone then { only refresh if percentage changed }
        Refresh;
    end;
  end;
  
  procedure TGauge.AddProgress(Value: Longint);
  begin
    Progress := FCurValue + Value;
    Refresh;
  
negative.code: 
  procedure TGauge.PaintBackground(AnImage: TBitmap);
  var
    LRect: TRect;
  begin
    with AnImage.Canvas do
    begin
      CopyMode := cmBlackness;
      LRect := Rect(0, 0, Width, Height);
      CopyRect(LRect, AnImage.Canvas, LRect);
      CopyMode := cmSrcCopy;
    end;
  end;
  
  procedure TGauge.PaintAsText(AnImage: TBitmap; APaintRect: TRect);
  var
    LS: string;
    LX, LY: integer;
    LOverBmp: TBitmap;
  begin
    LOverBmp := TBitmap.Create;
    try
      LOverBmp.MakeLike(AnImage);
      PaintBackground(LOverBmp);
      LS := Format('%d%%', [PercentDone]);
      with LOverBmp.Canvas do
      begin
        Brush.Style := bsClear;
        Font := Self.Font;
        Font.Color := clWhite;
        LX := (APaintRect.Right - APaintRect.Left + 1 - TextWidth(LS)) div 2;
        LY := (APaintRect.Bottom - APaintRect.Top + 1 - TextHeight(LS)) div 2;
        TextRect(APaintRect, LX, LY, LS);
      end;
      AnImage.Canvas.CopyMode := cmSrcInvert;
      AnImage.Canvas.Draw(0, 0, LOverBmp);
    finally
      LOverBmp.Free;
    end;
  end;
  
  procedure TGauge.PaintAsNothing(AnImage: TBitmap; APaintRect: TRect);
  begin
    with AnImage do
    begin
      Canvas.Brush.Color := BackColor;
      Canvas.FillRect(APaintRect);
    end;
  end;
  
  procedure TGauge.PaintAsBar(AnImage: TBitmap; APaintRect: TRect);
  var
    FillSize: LongInt;
    W, H: integer;
  begin
    W := APaintRect.Right - APaintRect.Left + 1;
    H := APaintRect.Bottom - APaintRect.Top + 1;
    with AnImage.Canvas do
    begin
      Brush.Color := BackColor;
      FillRect(APaintRect);
      Pen.Color := ForeColor;
      Pen.Width := 1;
      Brush.Color := ForeColor;
      case FKind of
        gkHorizontalBar:
        begin
          FillSize := SolveForX(PercentDone, W);
          if FillSize > W then
            FillSize := W;
          if FillSize > 0 then
            FillRect(Rect(APaintRect.Left, APaintRect.Top, FillSize, H));
        end;
        gkVerticalBar:
        begin
          FillSize := SolveForX(PercentDone, H);
          if FillSize >= H then
            FillSize := H - 1;
          FillRect(Rect(APaintRect.Left, H - FillSize, W, H));
        end;
      end;
    end;
  end;
  
  procedure TGauge.PaintAsPie(AnImage: TBitmap; APaintRect: TRect);
  var
    MiddleX, MiddleY: integer;
    Angle: double;
    W, H: integer;
  begin
    W := APaintRect.Right - APaintRect.Left;
    H := APaintRect.Bottom - APaintRect.Top;
    if FBorderStyle = bsSingle then
    begin
      Inc(W);
  