TMlSkinLabel

The skinned label: transparent background, rounded fill, separate horizontal and vertical alignment, and ellipsis handling for long text.

Category
Labels & hints
Unit
uMlSkinLabel.pas
Inherits from
TMlSkinCustomLabelTMlSkinCustomPanelTMlSkinCustomControl

Notes

  • With Transparent on it blends into the form background, so no solid block shows on a dark skin.
  • Horizontal and vertical alignment are set separately through AlignmentHorizontal and AlignmentVertical.
  • AutoSize resizes the control to fit the text; at a fixed size, EllipsisPosition decides how long text is truncated.
  • Turn on RoundBackground and set Color for a rounded tag-style label.

Example

From the demo MlSkin.Demo.圆角标签按钮和提示框.v3.0 (.dfm form file)

object lbl1: TMlSkinLabel
  Left = 14
  Top = 15
  Width = 98
  Height = 41
  Color = 5392355
  AutoInvalidate = True
  Alpha = 255
  AlignmentHorizontal = taCenter
  AlignmentVertical = taVerticalCenter
  AutoSize = False
  RoundBackground = True
  Caption = 'UserName'
  Light.Active = False
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWhite
  Font.Height = -12
  Font.Name = 'Tahoma'
  Font.Style = [fsBold]
  ParentFont = False

Properties 10

NameTypeDefaultDescription
AlphaByte192Opacity: 0 fully transparent, 255 opaque.
EllipsisPositionTEllipsisPositionepNoneWhere the ellipsis goes when text is too long: epEndEllipsis at the end, epPathEllipsis in the middle (good for paths), epWordEllipsis at a word boundary, epNone none.
AlignmentHorizontalTAlignmenttaLeftJustifyHorizontal text alignment: left, centred or right.
AlignmentVerticalTVerticalAlignmenttaAlignTopVertical text alignment: top, centred or bottom.
AutoSizeBooleanTrueWhether the control resizes itself to fit its content.
RoundBackgroundBooleanFalseDraws the background with rounded corners; combined with Color it gives a tag-style text block.
RoundSizeInteger5Corner radius in pixels; 0 means square corners.
LightTMlLightClassGlow effect: switch, glow color and blur radius.
WordWapBooleanFalseWhether long text wraps to the next line.
ColorTColorclWhiteBackground color of the control; ignored while Transparent is on.
Events of TMlSkinCustomPanel 1
NameTypeDefaultDescription
OnCustomDrawTMlCustomDrawEventCustom draw event: paint your own content after the control has drawn itself.
Properties of TMlSkinCustomControl 4
NameTypeDefaultDescription
AboutTMlAboutInfoA design-time property: double-clicking it in the Object Inspector opens the MLSkin about box with the component version. It has no effect at run time and is not stored in the .dfm.
TransparentBooleanTrueTransparent background: the control skips its own fill and shows the form background (image or color) instead.
AutoInvalidateBooleanFalseRepaints automatically when the content changes. Turn it on if property changes do not show up.
EraseBackgroundBooleanFalseWhether the background is erased before painting; worth toggling if the control flickers.
Events of TMlSkinCustomControl 4
NameTypeDefaultDescription
OnDPIChangedTMlDPIChangedEventFires when the screen DPI changes, for example when the window moves to a monitor with a different scaling — a good place to re-adjust anything you draw yourself.
OnBackgroundChangingTMlBackgroundEventFires just before the background changes, giving you a chance to adjust what is drawn.
OnBackgroundChangedTMlCustomDrawEventFires after the background has been drawn, so you can paint on top of it.
OnVisibleChangedTNotifyEventFires when the control is shown or hidden.

Only the properties and events MLSkin adds are listed here. Standard VCL properties such as Align, Anchors, Font and OnClick are available too and behave exactly as on the stock controls.

Offline helpA PDF / CHM version is available for offline reading.