Инструменты пользователя

Инструменты сайта


works:programmer:delphi:speedbutton-badge

Бейджик с циферками для TSpeedButton

    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;
works/programmer/delphi/speedbutton-badge.txt · Последнее изменение: 2022/09/25 18:42 — 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki