TMlSkinSwitchButton
A toggle switch for on/off state — a graphical stand-in for a check box.
Notes
- Read and write the state through
Checked;OnChangedfires when it changes. - Each state can have its own image:
ImageONandImageOFF. Without images the switch is drawn fromColor. - Text can sit next to the switch:
CaptionONandCaptionOFFper state, withCaptionAlignplacing it left or right.
Example
From the demo MlSkin.MainDemo.v3.0 (.dfm form file)
object mlsknswtchbtn1: TMlSkinSwitchButton
Left = 656
Top = 152
Width = 34
Height = 18
ImageOFF.Active = True
ImageOFF.Image = 'MlSkinSwitch_off'
ImageOFF.Normal = 0
ImageOFF.Hot = 1
ImageOFF.Disable = 0
ImageOFF.Count = 3
ImageOFF.Pressed = 2
ImageON.Active = True
ImageON.Image = 'MlSkinSwitch_on'
ImageON.Normal = 0
ImageON.Hot = 1
ImageON.Disable = 0
ImageON.Count = 3
ImageON.Pressed = 2
Checked = True
Properties 10
| Name | Type | Default | Description |
|---|---|---|---|
CanFocused | Boolean | True | Whether the control can take focus. With it off, clicking does not steal focus and Tab skips it. |
ImageOFF | TPngPictures | — | Image for the OFF state. |
ImageON | TPngPictures | — | Image for the ON state. |
Checked | Boolean | False | The switch state; True means on. Changing it fires OnChanged. |
CustomDraw | TSWBCustomDraw | — | Custom drawing settings, used to define how the switch is painted when no images are supplied. |
CaptionVisible | Boolean | — | Whether the caption is drawn. Turn it off for icon-only buttons. |
CaptionOFF | string | — | Text shown in the OFF state. |
CaptionON | string | — | Text shown in the ON state. |
CaptionAlign | TMlSwitchButtonCaptionAlign | sbcaLeft | Where the text sits: sbcaLeft to the left of the switch, sbcaRigth to the right. |
Color | TColor | clWhite | Color used when the switch is drawn without images. |
Events 1
| Name | Type | Default | Description |
|---|---|---|---|
OnChanged | TNotifyEvent | — | Fires when the switch state changes. |
Properties of TMlSkinCustomControl 4
| 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. |
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.
Offline helpA PDF / CHM version is available for offline reading.