TTMSFNCCustomControl Class
Base class for visual controls, adding fill, stroke, persistence, undo management, data binding, and custom draw events.
API unit family: TMSFNCCustomControl
Inherits from: TTMSFNCCustomControlBase
Implements: ITMSFNCGraphicsExport, ITMSFNCPersistence, ITMSFNCDataBinderSelection, ITMSFNCDataBinderNotificationManagerReference
Syntax
TTMSFNCCustomControl = class(TTMSFNCCustomControlBase, ITMSFNCGraphicsExport, ITMSFNCPersistence, ITMSFNCDataBinderSelection, ITMSFNCDataBinderNotificationManagerReference)
Properties
| Name | Description |
|---|---|
| AdaptToStyle | When True the control adapts its appearance colours to match the active IDE or application style. Default is False. (inherited from TTMSFNCCustomControlBaseCommon) |
| AllowFocus | When True (default) the control can receive keyboard focus. Set to False to prevent focus. (inherited from TTMSFNCCustomControlBaseCommon) |
| BlockPersistenceInterface | When True, the IPersistence interface is blocked globally for all controls in the hierarchy, preventing automatic JSON serialisation of persistence-aware properties. |
| BlockRepaint | When True calls to Invalidate are suppressed. Use around bulk property changes to avoid redundant repaints. |
| Color | Background colour of the control when Fill.Kind is not set. Defaults to gcWhite. |
| ControlAlignment | Framework-neutral alignment that positions the control relative to its parent. Defaults to caNone (manual placement). (inherited from TTMSFNCCustomControlBaseCommon) |
| DataBoolean | General-purpose Boolean data slot. True and False have caller-defined meaning. |
| DataInteger | General-purpose integer data slot for associating an arbitrary native integer value with the control. |
| DataObject | General-purpose object data slot for associating an arbitrary object reference with the control. |
| DataPointer | General-purpose untyped data slot for associating arbitrary pointer values with the control. |
| DataString | General-purpose string data slot for associating an arbitrary string value with the control. |
| DesigntimeFormPixelsPerInch | Pixels-per-inch value of the form as recorded at design time. Used internally to compute DPI scaling at runtime. (inherited from TTMSFNCCustomControlBaseCommon) |
| HitTest | When True (default) the control participates in mouse hit-testing and receives mouse events. (inherited from TTMSFNCCustomControlBase) |
| Left | Horizontal position of the control's left edge in pixels, relative to its parent. FMX only — use standard Left on other frameworks. (inherited from TTMSFNCCustomControlBase) |
| LocalRect | The usable client area of the control as a floating-point rectangle with origin (0, 0). (inherited from TTMSFNCCustomControlBase) |
| PaintScaleFactor | DPI scale factor applied during painting. Use ScalePaintValue to convert pixel sizes in custom drawing code. (inherited from TTMSFNCCustomControlBaseCommon) |
| ResourceScaleFactor | DPI scale factor applied when loading image resources (bitmaps). Use ScaleResourceValue to convert pixel sizes for resource loading. (inherited from TTMSFNCCustomControlBaseCommon) |
| ShowAcceleratorChar | When True (default) a character preceded by an ampersand in caption text is underlined as an accelerator key. (inherited from TTMSFNCCustomControlBaseCommon) |
| Stored | When True (default) the control's state is included when saving form/frame data. Set to False to exclude it. (inherited from TTMSFNCCustomControlBase) |
| Top | Vertical position of the control's top edge in pixels, relative to its parent. FMX only — use standard Top on other frameworks. (inherited from TTMSFNCCustomControlBase) |
| UndoManager | Provides access to the built-in undo/redo stack. Use to push, pop, or replay undoable operations. |
Methods
| Name | Description |
|---|---|
| BeginUpdate | Suspends visual updates for the web control implementation so multiple property changes can be applied without intermediate repaints. (inherited from TTMSFNCCustomControlBase) |
| CanFocus | Returns True when the control is able to receive keyboard focus. (inherited from TTMSFNCCustomControlBase) |
| DisableBackground | Temporarily disables drawing the control background so that custom code can paint the background manually. |
| DisableFill | Temporarily disables applying Fill during painting, allowing the background to show through. |
| DisableStroke | Temporarily disables drawing the Stroke border around the control. |
| DragDrop | Called by the framework when a drag-and-drop operation completes over the control. Dispatches to HandleDragDrop for cross-framework processing. (inherited from TTMSFNCCustomControlBase) |
| EnableBackground | Re-enables automatic background drawing after a DisableBackground call. |
| EnableFill | Re-enables applying Fill during painting after a DisableFill call. |
| EnableStroke | Re-enables drawing the Stroke border after a DisableStroke call. |
| EndUpdate | Re-enables visual updates for the web control implementation after a BeginUpdate call and triggers a repaint. (inherited from TTMSFNCCustomControlBase) |
| GetButtonBitmap | Returns the native OS button bitmap of the given size for use in custom drawing. Pass ADown, AFocused, and AEnabled to select the appropriate visual state. |
| GetCheckBoxBitmap | Returns the native OS checkbox bitmap for use in custom drawing. Pass AChecked, AFocused, and AEnabled to select the appropriate visual state. |
| GetControlMargins | Returns the four margin values of the control. (inherited from TTMSFNCCustomControlBaseCommon) |
| GetRadioButtonBitmap | Returns the native OS radio-button bitmap for use in custom drawing. Pass AChecked, AFocused, and AEnabled to select the appropriate visual state. |
| Invalidate | Schedules a full repaint of the control on the next paint cycle. (inherited from TTMSFNCCustomControlBase) |
| IsDesignTime | Returns True when the control is running inside the IDE at design time. |
| IsDesignerForm | Returns True when the control is placed on a design-time form class derived from TTMSFNCCustomDesignerForm. |
| IsDesigning | Returns True when the control is hosted on the IDE form designer. |
| IsDestroying | Returns True while the control is in the process of being destroyed. |
| IsLoading | Returns True while the owning form or data module is streaming its DFM content (i.e. during component loading). |
| IsReading | Returns True while the control's persistent properties are being read from a stream. |
| LoadSettingsFromFile | Deserialises settings from a previously saved JSON file and applies them to the control. |
| LoadSettingsFromStream | Deserialises settings from a JSON stream and applies them to the control. |
| NotifyDataBinderEdit | Notifies any attached data binder that the user has started editing a value. |
| NotifyDataBinderPost | Notifies any attached data binder to post the current edit to the underlying dataset. |
| NotifyDataBinderSetActiveRecord | Notifies any attached data binder to move to the active record in the underlying dataset. |
| NotifyDataBinderUpdate | Notifies any attached data binder to refresh its display from the underlying dataset. |
| NotifyDataBinderValueChanged | Notifies any attached data binder that the bound value has changed. |
| Paint | Renders the control onto its canvas. Called by the framework on every repaint cycle. |
| Resize | Called by the framework when the control is resized. Override to update internal layout after a size change. |
| SaveSettingsToFile | Serialises all (or only appearance) settings to a file in JSON format. |
| SaveSettingsToStream | Serialises all (or only appearance) settings to a stream in JSON format. |
| ScalePaintValue | Scales an integer value by the current paint DPI factor, returning the scaled integer. (inherited from TTMSFNCCustomControlBaseCommon) |
| ScaleResourceValue | Scales an integer value by the current resource DPI factor, returning the scaled integer. (inherited from TTMSFNCCustomControlBaseCommon) |
| SetControlMargins | Sets the four margin values of the control in one call. (inherited from TTMSFNCCustomControlBaseCommon) |
Events
| Name | Description |
|---|---|
| OnAfterDraw | Fired after the control has finished painting, allowing additional content to be drawn on top. |
| OnBeforeDraw | Fired just before the control paints its background. Set ADefaultDraw to False to take over painting completely. |
| OnCanLoadProperty | Fired for each property during settings deserialisation. Set ACanLoad to False to prevent a property value from being applied. |
| OnCanSaveProperty | Fired for each property during settings serialisation. Set ACanSave to False to exclude a specific property from the saved output. |