TComponent¶
Base class for all components that need owner-owned functionality.
Declaration¶
Source position: classesh.inc line 2613
type
TComponent = class(TPersistent, IUnknown, IInterfaceComponentReference)
public
TToStringNameMode = (snmNameClassName,snmClassName,snmName);
public
class var
ToStringNameMode: TToStringNameMode;
procedure WriteState;
constructor Create;
destructor Destroy;
procedure BeforeDestruction;
procedure DestroyComponents;
procedure Destroying;
function ExecuteAction : Boolean;
function FindComponent : TComponent;
procedure FreeNotification;
procedure RemoveFreeNotification;
procedure FreeOnRelease;
function GetEnumerator : TComponentEnumerator;
function GetNamePath : string;
function GetParentComponent : TComponent;
function HasParent : Boolean;
procedure InsertComponent;
procedure RemoveComponent;
function SafeCallException : HRESULT;
procedure SetSubComponent;
function UpdateAction : Boolean;
property ComObject: IUnknown; {r}
function IsImplementorOf : Boolean;
procedure ReferenceInterface;
function ToString : RTLString;
property Components[Index : Integer]: TComponent; {r}
property ComponentCount: Integer; {r}
property ComponentIndex: Integer; {rw}
property ComponentState: TComponentState; {r}
property ComponentStyle: TComponentStyle; {r}
property DesignInfo: LongInt; {rw}
property Owner: TComponent; {r}
property VCLComObject: Pointer; {rw}
property Observers: TObservers; {r}
property OnGetDeltaStreams: TGetDeltaStreamsEvent; {rw}
published
property Name: TComponentName; {rws}
property Tag: PtrInt; {rwd}
end;
Description¶
TComponent is the base class for any set of classes that needs owner-owned functionality, and which needs support for property streaming. All classes that should be handled by an IDE (Integrated Development Environment) must descend from TComponent, as it includes all support for streaming all its published properties.
Components can 'own' other components. TComponent introduces methods for enumerating the child components. It also allows to name the owned components with a unique name. Furthermore, functionality for sending notifications when a component is removed from the list or removed from memory altogether is also introduced in TComponent
TComponent introduces a form of automatic memory management: When a component is destroyed, all its child components will be destroyed first.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| ComObject read only | public | Interface reference implemented by the component. |
| ComponentCount read only | public | Count of owned components. |
| ComponentIndex | public | Index of component in it's owner's list. |
| Components read only | public | Indexed list (zero-based) of all owned components. |
| ComponentState read only | public | Current component's state. |
| ComponentStyle read only | public | Current component's style. |
| DesignInfo | public | Information for IDE designer. |
| Name | published | Name of the component. |
| Observers read only | public | |
| Owner read only | public | Owner of this component. |
| Tag | published | Tag value of the component. |
| VCLComObject | public | Not implemented. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| BeforeDestruction | public | Overrides standard BeforeDestruction. |
| Create | public | Creates a new instance of the component. |
| Destroy | public | Destroys the instance of the component. |
| DestroyComponents | public | Destroy child components. |
| Destroying | public | Called when the component is being destroyed. |
| ExecuteAction | public | Standard action execution method. |
| FindComponent | public | Finds and returns the named component in the owned components. |
| FreeNotification | public | Ask the component to notify called when it is being destroyed. |
| FreeOnRelease | public | Part of the IVCLComObject interface. |
| GetEnumerator | public | Create an IEnumerator instance. |
| GetNamePath | public | Returns the name path of this component. |
| GetParentComponent | public | Returns the parent component. |
| HasParent | public | Does the component have a parent ? |
| InsertComponent | public | Insert the given component in the list of owned components. |
| IsImplementorOf | public | Checks if the current component is the implementor of the interface. |
| Notification | protected | Called by components that are freed and which received a FreeNotification. |
| ReferenceInterface | public | Interface implementation of Notification. |
| RemoveComponent | public | Remove the given component from the list of owned components. |
| RemoveFreeNotification | public | Remove a component from the Free Notification list. |
| SafeCallException | public | Part of the IVCLComObject Interface. |
| SetSubComponent | public | Sets the csSubComponent style. |
| ToString | public | |
| UpdateAction | public | Updates the state of an action. |
| WriteState | public | Writes the component to a stream. |