Skip to content

TStyledGraphicButton - Technical Reference ​

Overview ​

TStyledGraphicButton is a pure graphic button control that provides styled rendering without focus or tab-stop capabilities. It's ideal for use in visual lists, toolbars, and scenarios where a lightweight button control is needed.

Class Hierarchy ​

TGraphicControl
  └─ TCustomStyledGraphicButton
      └─ TStyledGraphicButton

Unit ​

pascal
Vcl.StyledButton

Description ​

TStyledGraphicButton is a non-windowed control (derived from TGraphicControl) that renders buttons with custom styles. Unlike windowed controls, it cannot receive keyboard focus, making it perfect for toolbars, lists, and decorative UI elements where focus management isn't required.

All rendering is handled by an internal TStyledButtonRender instance, which provides consistent styling across all styled components in the library.

Key Features ​

  • Five button states: Normal, Pressed, Selected, Hot (hover), Disabled
  • Multiple style families: Classic, Bootstrap, Angular-Light, Angular-Dark, Basic-Color, SVG-Color
  • Custom shapes: Rectangle, RoundedRect, Rounded (full-round), Ellipse
  • Image support: ImageList with state-specific images (Normal, Hot, Pressed, Selected, Disabled)
  • Notification badge: Optional badge overlay with custom text and colors
  • VCL Styles integration: Can switch between styled and VCL rendering
  • GDI+ rendering: Smooth antialiased rendering independent of VCL Styles

Main Properties ​

Styling Properties ​

PropertyTypeDescription
StyleFamilyTStyledButtonFamilyStyle family (Classic, Bootstrap, Angular-Light, Angular-Dark, Basic-Color, SVG-Color)
StyleClassTStyledButtonClassPredefined style class within the family
StyleAppearanceTStyledButtonAppearanceVisual variant (Normal, Outline, Flat, Raised, etc.)
StyleDrawTypeTStyledButtonDrawTypeButton shape (btRect, btRoundRect, btRounded, btEllipse)
StyleRadiusIntegerCorner radius for btRoundRect (default: 6)
StyleRoundedCornersTRoundedCornersWhich corners to round ([rcTopLeft, rcTopRight, rcBottomLeft, rcBottomRight])

Appearance Properties ​

PropertyTypeDescription
CaptionTCaptionButton text
CaptionAlignmentTAlignmentCaption alignment (taLeftJustify, taCenter, taRightJustify)
ShowCaptionBooleanShow/hide caption (default: True)
WordWrapBooleanEnable text word-wrapping
FlatBooleanFlat button appearance
TransparentBooleanTransparent background (for graphic buttons only)

Image Properties ​

PropertyTypeDescription
ImagesTCustomImageListImageList for button images
ImageIndexTImageIndexDefault image index
ImageNameTImageNameImage name (Delphi 10.4+)
ImageAlignmentTImageAlignmentImage position (iaLeft, iaRight, iaTop, iaBottom, iaCenter)
ImageMarginsTImageMarginsMargins around the image
HotImageIndexTImageIndexImage when mouse hovers
PressedImageIndexTImageIndexImage when button is pressed
SelectedImageIndexTImageIndexImage when button is selected/down
DisabledImageIndexTImageIndexImage when button is disabled
DisabledImagesTCustomImageListSeparate ImageList for disabled state

State Properties ​

PropertyTypeDescription
DownBooleanButton pressed state (for toggle buttons)
GroupIndexIntegerButton group for radio-button behavior
AllowAllUpBooleanAllow all buttons in group to be unpressed
ModalResultTModalResultModal result value for forms

Custom Attributes ​

PropertyTypeDescription
ButtonStyleNormalTStyledButtonAttributesCustom attributes for normal state
ButtonStyleHotTStyledButtonAttributesCustom attributes for hot/hover state
ButtonStylePressedTStyledButtonAttributesCustom attributes for pressed state
ButtonStyleSelectedTStyledButtonAttributesCustom attributes for selected state
ButtonStyleDisabledTStyledButtonAttributesCustom attributes for disabled state

Notification Badge ​

PropertyTypeDescription
NotificationBadgeTNotificationBadgeAttributesBadge configuration (text, color, shape, visibility)

Compatibility ​

PropertyTypeDescription
AsVCLComponentBooleanSwitch to VCL-style rendering (uses VCL Styles if active)
GlyphTBitmapLegacy bitmap glyph (for TSpeedButton compatibility)
NumGlyphsTNumGlyphsNumber of glyphs in bitmap (1-4)

Main Methods ​

RegisterDefaultRenderingStyle (Class Method) ​

Sets the default rendering style for all TStyledGraphicButton instances created afterwards.

pascal
class procedure RegisterDefaultRenderingStyle(
  const ADrawType: TStyledButtonDrawType;
  const AFamily: TStyledButtonFamily = DEFAULT_CLASSIC_FAMILY;
  const AClass: TStyledButtonClass = DEFAULT_WINDOWS_CLASS;
  const AAppearance: TStyledButtonAppearance = DEFAULT_APPEARANCE;
  const AStyleRadius: Integer = DEFAULT_RADIUS;
  const ACursor: TCursor = DEFAULT_CURSOR); virtual;

Example:

pascal
// Set all buttons to Bootstrap Primary with rounded corners
TStyledGraphicButton.RegisterDefaultRenderingStyle(
  btRounded,
  BOOTSTRAP_FAMILY,
  btn_primary,
  BOOTSTRAP_NORMAL
);

Events ​

EventDescription
OnClickTriggered when button is clicked
OnMouseEnterMouse enters button area
OnMouseLeaveMouse leaves button area
OnMouseDownMouse button pressed
OnMouseUpMouse button released
OnMouseMoveMouse moves over button

Usage Examples ​

Basic Button ​

pascal
var
  Btn: TStyledGraphicButton;
begin
  Btn := TStyledGraphicButton.CreateStyled(Self,
    BOOTSTRAP_FAMILY,
    btn_primary,
    BOOTSTRAP_NORMAL);
  Btn.Parent := Self;
  Btn.Caption := 'Click Me';
  Btn.StyleDrawType := btRounded;
  Btn.OnClick := ButtonClick;
end;

Button with Image ​

pascal
Btn := TStyledGraphicButton.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_success,
  BOOTSTRAP_NORMAL);
Btn.Parent := Self;
Btn.Caption := 'Save';
Btn.Images := ImageList1;
Btn.ImageIndex := 0;
Btn.ImageAlignment := iaLeft;

Toggle Button ​

pascal
Btn := TStyledGraphicButton.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Btn.Parent := Self;
Btn.Caption := 'Bold';
Btn.AllowAllUp := True;
Btn.GroupIndex := 1;  // 0 = no grouping
Btn.Down := False;     // Initial state

Button with Notification Badge ​

pascal
Btn := TStyledGraphicButton.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_primary,
  BOOTSTRAP_NORMAL);
Btn.Parent := Self;
Btn.Caption := 'Messages';
Btn.NotificationBadge.Visible := True;
Btn.NotificationBadge.BadgeText := '5';
Btn.NotificationBadge.BadgeColor := clRed;

Custom Styled Button ​

pascal
Btn := TStyledGraphicButton.CreateStyled(Self,
  BOOTSTRAP_FAMILY,
  btn_secondary,
  BOOTSTRAP_NORMAL);
Btn.Parent := Self;
Btn.Caption := 'Custom';
Btn.ButtonStyleNormal.ButtonColor := $00FF8800;  // Orange
Btn.ButtonStyleNormal.BorderColor := clBlack;
Btn.ButtonStyleNormal.FontColor := clWhite;
Btn.ButtonStyleHot.ButtonColor := $00CC6600;     // Darker on hover

State-Specific Images ​

pascal
Btn := TStyledGraphicButton.Create(Self);
Btn.Images := ImageList1;
Btn.ImageIndex := 0;           // Normal state
Btn.HotImageIndex := 1;        // Hover state
Btn.PressedImageIndex := 2;    // Pressed state
Btn.DisabledImageIndex := 3;   // Disabled state

Important Notes ​

  • No Focus: TStyledGraphicButton cannot receive keyboard focus (no TabStop)
  • Lightweight: Uses less resources than windowed controls
  • Use in Lists: Perfect for TControlList, virtual lists, and custom-drawn lists
  • GDI+ Required: Requires Windows XP SP2+ for antialiased rendering
  • DPI Aware: Automatically scales with DPI changes

See Also ​

Released under Apache License, Version 2.0.