Notes
Pictures holds the button image — one picture split into normal, hot, pressed and disabled frames, with Count giving the number of frames.
- An icon layer can be drawn on top through
Layers and positioned with LayersOffset, so changing the icon does not mean redrawing the whole button.
- For an image-only button, turn
CaptionVisible off.
DropdownMenu attaches a popup menu that opens when the button is clicked.
Example
From the demo MlSkin.Demo.360云盘.v3.0 (.dfm form file)
object btn6: TMlSkinImageButton
Left = 852
Top = 8
Width = 18
Height = 18
AutoInvalidate = True
Down = False
HotFont.Charset = DEFAULT_CHARSET
HotFont.Color = clWindowText
HotFont.Height = -12
HotFont.Name = 'Tahoma'
HotFont.Style = []
DropdownMenuOffset.X = -4
DropdownMenuOffset.Y = -4
Anchors = [akTop, akRight]
Caption = 'btn6'
TabOrder = 3
TabStop = True
Pictures.Active = True
Pictures.Normal = 0
Properties 9
| Name | Type | Default | Description |
|---|
Streach | Boolean | False | Whether the image is stretched to the control size; with it off the image is drawn at its original size. |
Pictures | TPngPictures | — | The images used by the control, split into frames per state: unchecked, checked, hot, disabled. |
LayerMode | Boolean | False | Enables layer mode; only then is the image in Layers drawn. |
Layers | TPngPictures | — | An image layer drawn on top of the button, usually an icon. It is kept separate from the button background so the icon can change without redrawing the button. |
LayersOffset | TMlBtnItemOffset | — | Offset (X, Y) of the layer inside the button. |
CaptionVisible | Boolean | — | Whether the caption is drawn. Turn it off for icon-only buttons. |
CaptionOffset | TMlBtnItemOffset | — | Offset (X, Y) of the caption inside the control, for fine positioning. |
ImageOffset | TMlBtnItemOffset | — | Offset (X, Y) of the icon inside the control. |
DropdownMenu | TPopupMenu | — | The popup menu to attach. Once set, the button shows a dropdown arrow and clicking it opens the menu. |
Properties of TMlSkinCustomButton 15
| Name | Type | Default | Description |
|---|
About | TMlAboutInfo | — | A 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. |
AllowAllUp | Boolean | False | Whether all buttons in the group may be up at once. With it off, one button in the group always stays down. |
IgnoreMouse | Boolean | False | Ignores the mouse: the control stops responding and events pass through to whatever is underneath. |
CycleDownClick | Boolean | False | Repeats the click while the button is held down — useful for spin-style buttons. It fires OnCycleDownClick. |
WordWrap | Boolean | False | Whether long captions wrap to the next line. |
Down | Boolean | — | Whether the button is in the pressed state; combined with GroupIndex it behaves like a toggle or a tab. |
HotFont | TFont | — | Font used while the mouse is over the control, typically a different color or an underline for the hover effect. |
GroupIndex | Integer | 0 | Group number: buttons sharing a number are mutually exclusive, so only one stays down. 0 means no grouping. |
DropdownMenuOffset | TMlBtnItemOffset | — | Offset (X, Y) applied to where the dropdown menu pops up. |
PressedOffset | Integer | 1 | How many pixels the content shifts down-right while pressed, giving the push-in effect; 0 means no shift. |
CanFocused | Boolean | True | Whether the control can take focus. With it off, clicking does not steal focus and Tab skips it. |
Default | Boolean | False | Marks the default button: pressing Enter on the form clicks it. |
Cancel | Boolean | False | Marks the cancel button: pressing Esc on the form clicks it. |
ModalResult | TModalResult | 0 | The result returned to a modal form when the button is clicked, exactly as on the stock button. |
ShowFocusFrame | Boolean | False | Whether the dotted focus rectangle is drawn. |
Events of TMlSkinCustomButton 2
| Name | Type | Default | Description |
|---|
OnCustomPaint | TCustomPaintEvent | — | Custom paint event: take over drawing here when you want to paint the button yourself. |
OnCycleDownClick | TNotifyEvent | — | Fires repeatedly while the button is held down; requires CycleDownClick. |
Properties of TMlSkinCustomControl 5
| Name | Type | Default | Description |
|---|
About | TMlAboutInfo | — | A 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. |
Transparent | Boolean | True | Transparent background: the control skips its own fill and shows the form background (image or color) instead. |
Color | TColor | clWhite | Background color of the control; ignored while Transparent is on. |
AutoInvalidate | Boolean | False | Repaints automatically when the content changes. Turn it on if property changes do not show up. |
EraseBackground | Boolean | False | Whether the background is erased before painting; worth toggling if the control flickers. |
Events of TMlSkinCustomControl 4
| Name | Type | Default | Description |
|---|
OnDPIChanged | TMlDPIChangedEvent | — | Fires 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. |
OnBackgroundChanging | TMlBackgroundEvent | — | Fires just before the background changes, giving you a chance to adjust what is drawn. |
OnBackgroundChanged | TMlCustomDrawEvent | — | Fires after the background has been drawn, so you can paint on top of it. |
OnVisibleChanged | TNotifyEvent | — | Fires 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.