TMlSkinToolbar

A redesigned toolbar that runs horizontally or vertically. Each button can carry an icon, a caption and a dropdown menu, and it is often used as a tab-style navigation bar.

Category
Buttons & toolbars
Unit
uMlSkinToolbar.pas
Inherits from
TMlSkinCustomToolbarTMlSkinCustomPanelTMlSkinCustomControl

Notes

  • Buttons live in the Items collection; each one has its caption, image index, kind (button, separator and so on) and enabled state.
  • Icons come either from Images (a standard ImageList) or from ButtonImage (a multi-state picture).
  • Button size is set by ButtonWidth and ButtonHeight; with AutoButtonWidth on, width follows the caption and MaxButtonWidth caps it.
  • When the buttons do not fit, scroll buttons appear: ScrollButtonVisible shows or hides them and ScrollSize sets their size.
  • The background can be a color with transparency (Alpha) or an image (BackgroundImage) laid out by BackgroundFillType.
  • Clicking a button fires OnItemClick, which receives the clicked item.

Example

From the demo MlSkin.Demo.360云盘.v3.0 (.dfm form file)

object mlskntlbr1: TMlSkinToolbar
  Left = 0
  Top = 0
  Width = 201
  Height = 586
  Color = 16644854
  Items = <
  ...

Properties 28

NameTypeDefaultDescription
AllowArrowKeysBooleanFalseWhether the arrow keys move focus between the buttons.
AutoButtonWidthBooleanFalseWhether button width follows the caption length; with it off every button uses ButtonWidth.
DelayRefreshBooleanFalseDelays repainting, which cuts down redraws while a batch of buttons is being changed.
TextOffsetTMlBtnItemOffsetOffset (X, Y) of the button captions.
ItemsTMlSkinToolbarItemsThe buttons on the toolbar. Each item has its caption, image indexes (normal, hot, down, disabled), kind, enabled and down state, and an optional Action.
ImagesTCustomImageListThe ImageList the button icons come from; the image indexes on each item point into it.
ButtonImageTPngPicturesThe button background as a multi-state image, covering the normal, hot and pressed states.
ButtonWidthInteger48Button width in pixels.
MaxButtonWidthInteger0Maximum button width in pixels; 0 means unlimited. Use it with AutoButtonWidth to stop buttons growing too wide.
ButtonHeightInteger48Button height in pixels.
SpaceSizeInteger3Gap between buttons in pixels.
MultiLineBooleanFalseWhether buttons wrap to a second row when they do not fit.
DropdownMenuOffsetTMlBtnItemOffsetOffset (X, Y) applied to where the dropdown menu pops up.
ScrollSizeInteger15Size in pixels of the scroll buttons at each end.
ScrollButtonVisibleBooleanTrueWhether the scroll buttons appear at the ends when the buttons overflow.
MarginSizeInteger20Padding in pixels between the toolbar content and its edges.
MarginTextSizeInteger2Gap in pixels between an icon and its caption.
PressedOffsetInteger0How many pixels the button content shifts while pressed.
AlphaByte192Opacity of the toolbar background: 0 fully transparent, 255 opaque.
BorderSidesTSidesWhich border edges are drawn — any combination of top, bottom, left and right.
BorderColorTColor$00D9CBBABorder color.
BackgroundImageTMlResIDBackground image of the toolbar, given as an image ID or path.
BackgroundFillTypeTMlPngFillTypeftNormalHow the background image is laid out: as-is, tiled, auto-stretched, centred, stretched or gradient.
BackgroundOffsetXInteger0Horizontal offset of the background image in pixels.
BackgroundOffsetYInteger0Vertical offset of the background image in pixels.
DoubleBorderBooleanTrueDouble border: draws a second line inside the border.
FontHotTFontFont used while the mouse is over the control.
FontDownTFontFont used while the control is pressed.

Events 5

NameTypeDefaultDescription
OnItemClickTToolbarClickEventFires when a button is clicked; the clicked item is passed to the handler.
OnItemDownTToolbarClickEventFires when a button goes down, before the click completes.
OnItemFocusChangedTNotifyEventFires when focus moves from one button to another.
OnDrawItemTMlToolbarItemDrawEnventOwner-draw event for painting an individual item yourself.
OnButtonWidthChangedTToolbarButtonWidthEventFires after a button's width changes, mostly when AutoButtonWidth is on.
Properties of TMlSkinCustomPanel 1
NameTypeDefaultDescription
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 5
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.
ColorTColorclWhiteBackground color of the control; ignored while Transparent is on.
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.