procedure TfmMain.SetErrorsCount(ACount: Integer);
var
bmBadge : TBitmap;
strCount: string;
nPos : TPoint;
begin
bmBadge := TBitmap.Create;
with bmBadge do try
Width := 24;
Height := 24;
Canvas.Brush.Color := clFuchsia; // Transperent Background_
Canvas.Brush.Style := bsSolid;
Canvas.FillRect(Rect(0, 0, Width, Height));
Canvas.Pen.Style := psClear; // Badge Background_
Canvas.Brush.Color := Colors.Danger;
Canvas.RoundRect(0, 0, Width, Height, 6, 6);
Canvas.Font.Color := Colors.White; // Badge text
Canvas.Brush.Style := bsClear;
strCount := IntToStr(ACount);
if ACount > 999 then begin
Canvas.Font.Size := 8;
strCount := 'MAX';
end else if ACount > 99 then
Canvas.Font.Size := 9
else if ACount > 9 then
Canvas.Font.Size := 12
else
Canvas.Font.Size := 14;
nPos.X := (Width - Canvas.TextWidth(strCount)) div 2;
nPos.Y := (Height - Canvas.TextHeight(strCount)) div 2;
Canvas.TextOut(nPos.X, nPos.Y, strCount);
SpeedButton2.Glyph.Assign(bmBadge);
finally
FreeAndNil(bmBadge);
end;
end;