TMlSkinColorButton

A button painted in solid colors — no images required. A few color properties give you a flat-style button.

Category
Buttons & toolbars
Unit
uMlSkinColorButton.pas
Inherits from
TMlSkinCustomColorButtonTMlSkinCustomButtonTMlSkinCustomControl

Notes

  • One color per state: NormalColor, HotColor on hover and PressedColor while pressed.
  • For rounded buttons turn on RoundFrame, set the radius with RoundSize, and use SmoothRound for smoother edges.
  • BorderColor and BorderSides control the border color and which edges are drawn.
  • Add an icon with Image, and a different one on hover with HotImage.

Example

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

object btn5: TMlSkinColorButton
  Left = 11
  Top = 6
  Width = 79
  Height = 28
  AutoInvalidate = True
  Down = False
  HotFont.Charset = DEFAULT_CHARSET
  HotFont.Color = clWhite
  HotFont.Height = -11
  HotFont.Name = 'Tahoma'
  HotFont.Style = []
  DropdownMenuOffset.X = -4
  DropdownMenuOffset.Y = -4
  Font.Charset = DEFAULT_CHARSET
  Font.Color = 8609875
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  ParentFont = False

Properties 15

NameTypeDefaultDescription
AlphaByte255Button opacity: 0 fully transparent, 255 opaque.
CaptionVisibleBooleanWhether the caption is drawn. Turn it off for icon-only buttons.
CaptionOffsetTMlBtnItemOffsetOffset (X, Y) of the caption inside the control, for fine positioning.
DropdownMenuTPopupMenuThe popup menu to attach. Once set, the button shows a dropdown arrow and clicking it opens the menu.
ImageOffsetTMlBtnItemOffsetOffset (X, Y) of the icon inside the control.
ImageTMlResIDIcon shown on the button.
HotImageTMlResIDIcon shown while the mouse is over the button.
NormalColorTColor$003854FFButton color in the normal state.
PressedColorTColor$001A1A9DButton color while pressed.
HotColorTColor$004343E0Button color while the mouse is over it.
BorderColorTColor$00DFCBBBBorder color.
BorderSidesTSidesWhich border edges are drawn — any combination of top, bottom, left and right.
RoundFrameBooleanFalseDraws the button with rounded corners.
RoundSizeInteger3Corner radius in pixels.
SmoothRoundBooleanTrueAnti-aliases the rounded corners for smoother edges.
Properties of TMlSkinCustomButton 15
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.
AllowAllUpBooleanFalseWhether all buttons in the group may be up at once. With it off, one button in the group always stays down.
IgnoreMouseBooleanFalseIgnores the mouse: the control stops responding and events pass through to whatever is underneath.
CycleDownClickBooleanFalseRepeats the click while the button is held down — useful for spin-style buttons. It fires OnCycleDownClick.
WordWrapBooleanFalseWhether long captions wrap to the next line.
DownBooleanWhether the button is in the pressed state; combined with GroupIndex it behaves like a toggle or a tab.
HotFontTFontFont used while the mouse is over the control, typically a different color or an underline for the hover effect.
GroupIndexInteger0Group number: buttons sharing a number are mutually exclusive, so only one stays down. 0 means no grouping.
DropdownMenuOffsetTMlBtnItemOffsetOffset (X, Y) applied to where the dropdown menu pops up.
PressedOffsetInteger1How many pixels the content shifts down-right while pressed, giving the push-in effect; 0 means no shift.
CanFocusedBooleanTrueWhether the control can take focus. With it off, clicking does not steal focus and Tab skips it.
DefaultBooleanFalseMarks the default button: pressing Enter on the form clicks it.
CancelBooleanFalseMarks the cancel button: pressing Esc on the form clicks it.
ModalResultTModalResult0The result returned to a modal form when the button is clicked, exactly as on the stock button.
ShowFocusFrameBooleanFalseWhether the dotted focus rectangle is drawn.
Events of TMlSkinCustomButton 2
NameTypeDefaultDescription
OnCustomPaintTCustomPaintEventCustom paint event: take over drawing here when you want to paint the button yourself.
OnCycleDownClickTNotifyEventFires repeatedly while the button is held down; requires CycleDownClick.
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.