Skip to content

TStyledBitBtn - Technical Reference ​

Overview ​

TStyledBitBtn is the styled replacement of the VCL TBitBtn: a windowed button (focus, Default, Cancel, ModalResult) with Kind, Glyph, NumGlyphs, Layout, Margin and Spacing. It derives from TCustomStyledButton, as TStyledButton (it is not a descendant of it).

Guide with examples: TStyledBitBtn.

Class Hierarchy ​

TCustomControl
  └─ TCustomStyledButton
      └─ TStyledBitBtn

Unit ​

pascal
Vcl.StyledButton

Key Features ​

  • Kind (bkOK, bkCancel, bkYes, bkNo, bkAbort, bkRetry, bkIgnore, bkAll, bkClose, bkHelp, bkCustom): caption, ModalResult, Default/Cancel and glyph
  • Layout, Margin, Spacing (default 4), Glyph, NumGlyphs as TBitBtn
  • Same style, state, badge, AutoClick features of TStyledButton
  • Style is the TBitBtn compatibility property (bsAutoDetect), without effect; split button, command link, Flat, DisabledImages, ElevationRequired are available only in code (not published)

Published Properties ​

The properties of the published section are the ones shown in the Object Inspector. Properties marked "(published from Delphi 10.4)" are published only when the D10_4+ condition of the library is defined.

Style (family, class, appearance, shape) ​

PropertyTypeDefaultDescription
AsVCLComponentBooleanFalseWhen True the button is drawn like a standard VCL button (switches to Classic/Windows/Normal and adds seClient to StyleElements). Never stored in the DFM.
StyleElementsTStyleElementsStandard VCL property: with seClient the Classic family follows the active VCL Style. See AsVCLComponent.
StyleNamestring''VCL Style name (Delphi 10.4+): when set, the button switches to the Classic family and uses the style name as StyleClass, so it follows that VCL Style.
StyleRadiusInteger6Corner radius in pixels, used by btRoundRect (DEFAULT_RADIUS).
StyleShadowSizeInteger-1Shadow below the face of the button in pixels (at 100% scale), the same in every state: -1 = the shadow of the style family (DEFAULT_SHADOW_SIZE; the Elevated and Fab appearances of Angular-M3 have one), 0 = no shadow, a value greater than zero = that shadow in any family. It is seen only below the button and drawn inside the area of the control, so the face is shorter by the shadow size. Values below -1 raise an exception.
StyleRoundedCornersTRoundedCornersall four cornersSet of corners to round: rcTopLeft, rcTopRight, rcBottomRight, rcBottomLeft (ALL_ROUNDED_CORNERS).
StyleDrawTypeTStyledButtonDrawTypebtRoundRectShape: btRoundRect, btRounded, btRect, btEllipse. Stored only when different from the default.
StyleFamilyTStyledButtonFamily (string)'Classic'Style family: Classic, Bootstrap, Angular-Light, Angular-Dark, Angular-M3-Light, Angular-M3-Dark, Basic-Colors, SVG-Colors (or a custom registered family). The default can be changed with RegisterDefaultRenderingStyle.
StyleClassTStyledButtonClass (string)'Windows'Predefined style inside the family (e.g. Primary in Bootstrap, Basic in Angular-M3).
StyleAppearanceTStyledButtonAppearance (string)'Normal'Visual variant of the family (Normal/Outline, Flat/Raised/Basic/Stroked, Text/Elevated/Outlined/Filled/Tonal...).

State attributes ​

PropertyTypeDefaultDescription
ButtonStyleNormalTStyledButtonAttributes(from style)Colors, border and shape attributes of the Normal state. Filled from the style; stored only if customized.
ButtonStylePressedTStyledButtonAttributes(from style)Colors, border and shape attributes of the Pressed state. Filled from the style; stored only if customized.
ButtonStyleSelectedTStyledButtonAttributes(from style)Colors, border and shape attributes of the Selected state. Filled from the style; stored only if customized.
ButtonStyleHotTStyledButtonAttributes(from style)Colors, border and shape attributes of the Hot state. Filled from the style; stored only if customized.
ButtonStyleDisabledTStyledButtonAttributes(from style)Colors, border and shape attributes of the Disabled state. Filled from the style; stored only if customized.

Caption and appearance ​

PropertyTypeDefaultDescription
CaptionTCaption''Button text (supports the & accelerator in windowed buttons).
ShowCaptionBooleanTrueShow or hide the caption (useful for icon-only buttons).
FontTFontCaption font. The font color is overridden by the style unless the attributes are customized.
WordWrapBooleanFalseWraps the caption on more lines.
ParentFontBooleanTrueInherits the font of the parent.

Images and glyph ​

PropertyTypeDefaultDescription
DisabledImageIndexTImageIndex-1Image when the button is disabled. (published from Delphi 10.4)
DisabledImageNameTImageName''Name version of DisabledImageIndex (Delphi 10.4+).
HotImageIndexTImageIndex-1Image when the mouse is over the button. (published from Delphi 10.4)
HotImageNameTImageName''Name version of HotImageIndex (Delphi 10.4+).
ImageIndexTImageIndex-1Image of the normal state. (published from Delphi 10.4)
ImageNameTImageName''Name of the image in a name-aware list (Delphi 10.4+); alternative to ImageIndex.
ImagesTCustomImageListnilImage list used for the button images. (published from Delphi 10.4)
GlyphTBitmapLegacy bitmap (TSpeedButton/TBitBtn compatibility). With Kind <> bkCustom the default glyph of the Kind is used.
KindTBitBtnKindbkCustomPredefined button type: sets Caption, ModalResult, Default/Cancel and draws the default glyph (see TStyledBitBtn).
LayoutTButtonLayoutblGlyphLeftPosition of the image relative to the caption: blGlyphLeft, blGlyphRight, blGlyphTop, blGlyphBottom.
MarginInteger-1Distance between the border and the image/caption block (-1 = centered).
NumGlyphsTNumGlyphs1Number of images (1-4) in Glyph, side by side: up, disabled, clicked (down), down in a group (exclusive), as in TSpeedButton.
SpacingInteger4Distance in pixels between image and caption.
PressedImageIndexTImageIndex-1Image when the button is pressed.
SelectedImageIndexTImageIndex-1Image when the button is selected (focused).
PressedImageNameTImageName''Name version of PressedImageIndex (Delphi 10.4+).
SelectedImageNameTImageName''Name version of SelectedImageIndex (Delphi 10.4+).

Behavior ​

PropertyTypeDefaultDescription
ActionTBasicActionnilLinked action (caption, enabled, image, group, checked).
AutoClickBooleanFalseWhen True the button fills itself and fires the click after AutoClickDelay ms (see AutoClick guide). Reset to False after the click.
AutoClickDelayInteger5000Delay in milliseconds before the automatic click (DEFAULT_AUTOCLICK_DELAY).
CancelBooleanFalseCancel button of the form (Esc key).
CursorTCursorcrHandPointMouse cursor (DEFAULT_CURSOR).
DefaultBooleanFalseDefault button of the form (Enter key).
DoubleBufferedBooleanTrueDouble buffered painting (flicker free).
EnabledBooleanTrueEnables/disables the button (Disabled state style).
ModalResultTModalResultmrNoneValue assigned to the ModalResult of the parent form on click. It also drives the style of families that map ModalResult to a class (e.g. mrOk = Success in Bootstrap).
StyleVcl.Buttons.TButtonStylebsAutoDetectCompatibility with the TBitBtn property: it has no effect on the rendering (no split button or command link in TStyledBitBtn).
TabOrderTTabOrderPosition in the tab order.
TabStopBooleanTrueThe button can be reached with the Tab key.
ParentDoubleBufferedBooleanInherits DoubleBuffered from the parent.

Notification badge ​

PropertyTypeDefaultDescription
NotificationBadgeTNotificationBadgeAttributesBadge (counter or dot) drawn on the button: NotificationCount, CustomText, MaxNotifications, Position, Size, Color, FontColor, FontStyle. See Notification Badge.

Standard VCL properties ​

PropertyTypeDefaultDescription
AlignTAlignalNoneStandard VCL property.
AnchorsTAnchors[akLeft, akTop]Standard VCL property.
BiDiModeTBiDiModeStandard VCL property.
ConstraintsTSizeConstraintsStandard VCL property.
DragCursorTCursorcrDragStandard VCL property.
DragKindTDragKinddkDragStandard VCL property.
DragModeTDragModedmManualStandard VCL property.
TagInteger0Standard VCL property.
VisibleBooleanTrueStandard VCL property.
ParentBiDiModeBooleanTrueStandard VCL property.
ParentCustomHintBooleanTrueStandard VCL property.
ParentShowHintBooleanTrueStandard VCL property.
PopupMenuTPopupMenunilStandard VCL property.
ShowHintBooleanStandard VCL property.

Public Properties (not published) ​

Available in code, not shown in the Object Inspector (or published by a sibling component).

PropertyTypeDefaultDescription
ActiveStyleNamestringRead-only: name of the VCL Style currently applied to the button.
ButtonStateTStyledButtonStateRead-only: current visual state (bsmNormal, bsmPressed, bsmSelected, bsmHot, bsmDisabled).
MouseInControlBooleanRead-only: True while the mouse is over the button.
StyleAppliedBooleanTrue when the attributes of the style have been resolved (lazy resolution).
RenderTStyledButtonRenderThe internal renderer that holds all the style logic (advanced use).
RescalingButtonBooleanTrue while the button is being rescaled for a DPI change.
CaptionAlignmentTAlignmenttaCenterHorizontal alignment of the caption.
CommandLinkHintstring''Second line of text of a command link (Style = bsCommandLink).
ImageAlignmentTImageAlignmentiaLeftiaLeft, iaRight, iaTop, iaBottom, iaCenter.
DisabledImagesTCustomImageListnilSeparate image list used in the disabled state.
DropDownMenuTPopupMenunilPopup menu of the split button, shown under the button.
ElevationRequiredBooleanFalseShows the Windows UAC shield on the button.
FlatBooleanFalseFlat appearance (TSpeedButton/TBitBtn compatibility).
StylusHotImageIndexTImageIndex-1Image for stylus/touch hover.
StylusHotImageNameTImageName''Name version of StylusHotImageIndex (Delphi 10.4+).
ImageMarginsTImageMarginsLeft = 8Margins around the image (Left/Top/Right/Bottom); default depends on ImageAlignment.
AllowAllUpBooleanFalseWith GroupIndex, allows all the buttons of the group to be up.
GroupIndexInteger0Non-zero: the button belongs to a group of mutually exclusive buttons (same parent).
DownBooleanFalsePressed state of a grouped (toggle) button.

Public Methods ​

MethodDescription
constructor Create(AOwner: TComponent)Creates the button with the default style (see RegisterDefaultRenderingStyle).
constructor CreateStyled(AOwner; const AFamily; const AClass; const AAppearance)Creates the button with the given family, class and appearance.
constructor CreateStyled(AOwner; AFamily; AClass; AAppearance; const ADrawType: TStyledButtonDrawType; const ACursor: TCursor; const AUseCustomDrawType: Boolean)Creates the button choosing also the shape and the cursor.
class procedure RegisterDefaultRenderingStyle(const ADrawType; const AFamily = DEFAULT_CLASSIC_FAMILY; const AClass = DEFAULT_WINDOWS_CLASS; const AAppearance = DEFAULT_APPEARANCE; const AStyleRadius = DEFAULT_RADIUS; const ACursor = DEFAULT_CURSOR)Sets the default style used by all the TStyledButton and TStyledBitBtn created afterwards.
procedure SetButtonStyle(const AStyleFamily; const AStyleClass; const AStyleAppearance)Sets family, class and appearance at once (an empty value keeps the current one); raises an error if the combination does not exist.
procedure SetButtonStyle(const AStyleFamily; const AModalResult: TModalResult)Sets the family and chooses class and appearance from the ModalResult (as the family defines).
procedure AssignStyleTo(ADestRender: TStyledButtonRender)Copies the style settings to a render.
procedure AssignStyleTo(ADest: TCustomStyledButton)Copies the style settings (family, class, appearance, shape, state attributes, badge) to another button.
procedure AssignTo(ADest: TPersistent)Copies the properties of the button to another button (used by Assign).
function AssignAttributes(const AEnabled; const AImageList; const AImageName; const AImageIndex; const AImageAlignment; const AAction; const AOnClick; const AName): TCustomStyledButtonSets several attributes in one call and returns the button (for chaining). AImageName exists from Delphi 10.4. In a TStyledSpeedButton/TStyledBitBtn, passing an image list switches the positioning from Layout/Margin/Spacing to ImageAlignment/ImageMargins.
procedure ClickExecutes the click: sets the ModalResult of the parent form and fires OnClick (or the drop-down if the mouse is on the arrow of a split button).
procedure ShowDropDownMenuShows DropDownMenu under the button.
procedure DoDropDownMenuFires OnDropDownClick if assigned, otherwise shows DropDownMenu.
function GetSplitButtonWidth: IntegerWidth of the arrow area of a split button.
procedure BeginUpdate / procedure EndUpdateSuspends / resumes the repaint while changing many properties.
function GetRescalingButton: Boolean / procedure SetRescalingButtonAccessors of RescalingButton.
procedure ReleasePaintBufferReleases the shared off-screen bitmap used by the double buffered painting.

Events ​

EventDescription
OnClickButton clicked (mouse, keyboard or AutoClick).
OnContextPopupContext menu requested.
OnDragDropObject dropped on the button.
OnDragOverObject dragged over the button.
OnEndDockDocking ended.
OnEndDragDrag operation ended.
OnEnterThe button received the focus.
OnExitThe button lost the focus.
OnKeyDownKey pressed while the button has the focus.
OnMouseActivateMouse click is activating the control.
OnMouseDownMouse button pressed on the button.
OnMouseEnterMouse entered the button.
OnMouseLeaveMouse left the button.
OnMouseMoveMouse moved over the button.
OnMouseUpMouse button released.
OnStartDockDocking started.
OnStartDragDrag operation started.
OnDropDownClickClick on the arrow of a split button. When assigned it replaces the automatic display of DropDownMenu (call ShowDropDownMenu yourself if you need it). The Sender is the internal TStyledButtonRender (use Render.OwnerControl or TStyledButtonRender(Sender).OwnerControl to get the button). (public, not published)
OnKeyUpKey released while the button has the focus. (public, not published)

Kind ​

Setting Kind to a value different from bkCustom (not when loading a form that already has a caption):

KindCaptionModalResultDefaultCancel
bkOKOKmrOkTrueFalse
bkCancelCancelmrCancelFalseTrue
bkYesYesmrYesTrueFalse
bkNoNomrNoFalseTrue
bkAbortAbortmrAbortFalseFalse
bkRetryRetrymrRetryFalseFalse
bkIgnoreIgnoremrIgnoreFalseFalse
bkAllAllmrAllFalseFalse
bkCloseClosemrNoneFalseFalse
bkHelpHelpmrNoneFalseFalse
bkCustom(unchanged)(unchanged)(unchanged)(unchanged)

The default glyph of the Kind is drawn when no Glyph is assigned. If you later change ModalResult, Default or Cancel so that they no longer match the Kind, Kind reads back as bkCustom (changing the Caption does not affect it).

RegisterDefaultRenderingStyle ​

pascal
// In the .dpr, after Application.Initialize
TStyledBitBtn.RegisterDefaultRenderingStyle(btRounded, BOOTSTRAP_FAMILY, btn_primary, BOOTSTRAP_NORMAL);

The default style is shared with TStyledButton (same base class TCustomStyledButton).

Shadow (StyleShadowSize) ​

StyleShadowSize is a published property of the component (default -1 = DEFAULT_SHADOW_SIZE, declared in Vcl.ButtonStylesAttributes), like StyleRadius. With -1 the shadow is the one of the style family (the Elevated appearance of Angular-M3 has 2 pixels, 3 on hover, 0 when disabled; Fab has 3, 4 and 0; the other families have none). A value >= 0 replaces it with the same shadow in every state and in any family (0 removes it). The shadow is seen only below the button, inside the area of the control: the face is shorter by the biggest shadow of the five states, the top and the sides are unchanged. It is saved in the form file only if different from -1; values below -1 raise an exception.

The shadow of the family is available in ButtonStyleNormal.ShadowSize, ButtonStyleHot.ShadowSize... (public, not saved property of TStyledButtonAttributes, set by the family: see How to build your custom style). See the section Shadow (StyleShadowSize) of the component page.

See also ​

Released under Apache License, Version 2.0.