Hi I have a code by @wp that draws a progress bar, in the code the constant MAX_COUNTER is used. My question is how to replace the constant MAX_COUNTER with an Integer variable. I tried but I get an error dividing by zero.
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
R: TRect;
begin
Paintbox1.Canvas.Brush.Color := clWhite;
Paintbox1.Canvas.Pen.Color := clBlack;
Paintbox1.Canvas.Rectangle(0, 0, Paintbox1.Width, Paintbox1.Height);
R := Rect(2, 2, Paintbox1.Width * FCounter div MAX_COUNTER -2, Paintbox1.Height -2);
Paintbox1.Canvas.Brush.Color := RGB(169, 43, 79);
Paintbox1.Canvas.FillRect(R);
end;