TCustomVariantType = class(TObject)
Inherited Class Members: Variants.TCustomVariantType Members
Class Properties: Variants.TCustomVariantType Properties
Class Methods: Variants.TCustomVariantType Methods
Class Constructors & Destructors: Variants.TCustomVariantType Constructors
TCustomVariantType is the base class for Delphi custom variant types.
Use TCustomVariantType to define new data types for Delphi Variants. TCustomVariantType descendants do not represent the Variants themselves. Rather, they act as utility classes that the custom Variants call on to perform their operations.
To create a Variant type,
1.Map the storage of the Variant's data on to the TVarData record.
3.Declare a class that descends from TCustomVariantType.
4.Implement all required behavior (including type conversion rules) in the new class. This involves overriding the appropriate virtual methods (typically BinaryOp, UnaryOp, CompareOp or Compare, Cast, CastTo, Clear, Copy, IsClear, LeftPromotion, and RightPromotion).
5.In the initialization section of the unit that defines your TCustomVariantType descendant, create an instance of your class. When you instantiate your object, it automatically registers itself with the Variant-handling system so that the new Variant type is enabled.
6.In the finalization section of the unit that defines your TCustomVariantType descendant, free the instance of your class. This automatically unregisters the Variant type.
Note: C++ can use Custom Variant types, but TCustomVariantType descendants must be implemented in Delphi.
For an example, see the FMTBcd unit, which implements a custom Variant type for binary-coded decimal.
Tip: To create a custom Variant that allows users to call methods or procedures and to get or set property values, use TInvokeableVariantType as a base class instead.