Skip to content

TComponent

[Properties (by Name)][Methods (by Name)][Events (by Name)]

Base class for all components that need owner-owned functionality.

Declaration

Source position: classesh.inc line 2044

Type
  TComponent = class (TPersistent, IUnknown, IInterfaceComponentReference)
  private
    FOwner : TComponent;
    FName : TComponentName;
    FTag : PtrInt;
    FComponents : TFPList;
    FFreeNotifies : TFPList;
    FDesignInfo : LongInt;
    FVCLComObject : Pointer;
    FComponentState : TComponentState;
    function GetComObject : IUnknown;
    function GetComponent(AIndex: Integer) : TComponent;
    function GetComponentCount : Integer;
    function GetComponentIndex : Integer;
    procedure Insert(AComponent: TComponent);
    procedure ReadLeft(Reader: TReader);
    procedure ReadTop(Reader: TReader);
    procedure Remove(AComponent: TComponent);
    procedure RemoveNotification(AComponent: TComponent);
    procedure SetComponentIndex(Value: Integer);
    procedure SetReference(Enable: Boolean);
    procedure WriteLeft(Writer: TWriter);
    procedure WriteTop(Writer: TWriter);
  protected
    FComponentStyle : TComponentStyle;
    procedure ChangeName(const NewName: TComponentName);
    procedure DefineProperties(Filer: TFiler);  Override;
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent);  Dynamic;
    function GetChildOwner : TComponent;  Dynamic;
    function GetChildParent : TComponent;  Dynamic;
    function GetOwner : TPersistent;  Override;
    procedure Loaded;  Virtual;
    procedure Loading;  Virtual;
    procedure Notification(AComponent: TComponent; Operation: TOperation)
                          ;  Virtual;
    procedure PaletteCreated;  Dynamic;
    procedure ReadState(Reader: TReader);  Virtual;
    procedure SetAncestor(Value: Boolean);
    procedure SetDesigning(Value: Boolean; SetChildren: Boolean);
    procedure SetDesignInstance(Value: Boolean);
    procedure SetInline(Value: Boolean);
    procedure SetName(const NewName: TComponentName);  Virtual;
    procedure SetChildOrder(Child: TComponent; Order: Integer);  Dynamic;
    procedure SetParentComponent(Value: TComponent);  Dynamic;
    procedure Updating;  Dynamic;
    procedure Updated;  Dynamic;
    class procedure UpdateRegistry(Register: Boolean; 
                                  const ClassID: string; 
                                  const ProgID: string);  Dynamic;
    procedure ValidateRename(AComponent: TComponent; const CurName: string; 
                            const NewName: string);  Virtual;
    procedure ValidateContainer(AComponent: TComponent);  Dynamic;
    procedure ValidateInsert(AComponent: TComponent);  Dynamic;
    function QueryInterface(const IID: TGuid; out Obj) : HRESULT;  Virtual;
    function _AddRef : LongInt;
    function _Release : LongInt;
    function iicrGetComponent : TComponent;
    function GetTypeInfoCount(out Count: Integer) : HRESULT;
    function GetTypeInfo(Index: Integer; LocaleID: Integer; out TypeInfo)
                         : HRESULT;
    function GetIDsOfNames(const IID: TGuid; Names: Pointer; 
                          NameCount: Integer; LocaleID: Integer; 
                          DispIDs: Pointer) : HRESULT;
    function Invoke(DispID: Integer; const IID: TGuid; LocaleID: Integer; 
                   Flags: Word; var Params; VarResult: Pointer; 
                   ExcepInfo: Pointer; ArgErr: Pointer) : HRESULT;
  public
    procedure WriteState(Writer: TWriter);  Virtual;
    constructor Create(AOwner: TComponent);  Virtual;
    destructor Destroy;  Override;
    procedure BeforeDestruction;  Override;
    procedure DestroyComponents;
    procedure Destroying;
    function ExecuteAction(Action: TBasicAction) : Boolean;  Dynamic;
    function FindComponent(const AName: string) : TComponent;
    procedure FreeNotification(AComponent: TComponent);
    procedure RemoveFreeNotification(AComponent: TComponent);
    procedure FreeOnRelease;
    function GetEnumerator : TComponentEnumerator;
    function GetNamePath : string;  Override;
    function GetParentComponent : TComponent;  Dynamic;
    function HasParent : Boolean;  Dynamic;
    procedure InsertComponent(AComponent: TComponent);
    procedure RemoveComponent(AComponent: TComponent);
    function SafeCallException(ExceptObject: TObject; 
                              ExceptAddr: CodePointer) : HRESULT;  Override;
    procedure SetSubComponent(ASubComponent: Boolean);
    function UpdateAction(Action: TBasicAction) : Boolean;  Dynamic;
    ComObject : IUnknown;
    function IsImplementorOf(const Intf: IInterface) : Boolean;
    procedure ReferenceInterface(const intf: IInterface; op: TOperation);
    Components[Index: Integer]: TComponent;
    ComponentCount : Integer;
    ComponentIndex : Integer;
    ComponentState : TComponentState;
    ComponentStyle : TComponentStyle;
    DesignInfo : LongInt;
    Owner : TComponent;
    VCLComObject : Pointer;
  published
    Name : TComponentName;
    Tag : PtrInt;
  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.

Members

Member Type Visibility Description
BeforeDestruction Method public Overrides standard BeforeDestruction.
ChangeName Method protected Actually sets the component name.
ComObject Property public Interface reference implemented by the component
ComponentCount Property public Count of owned components
ComponentIndex Property public Index of component in it's owner's list.
Components Property public Indexed list (zero-based) of all owned components.
ComponentState Property public Current component's state.
ComponentStyle Property public Current component's style.
Create Method public Creates a new instance of the component.
DefineProperties Method protected Defines fake top,left properties for handling in the IDE.
DesignInfo Property public Information for IDE designer.
Destroy Method public Destroys the instance of the component.
DestroyComponents Method public Destroy child components.
Destroying Method public Called when the component is being destroyed
ExecuteAction Method public Standard action execution method.
FComponents Field private
FComponentState Field private
FComponentStyle Field protected Contains the component's style.
FDesignInfo Field private
FFreeNotifies Field private
FindComponent Method public Finds and returns the named component in the owned components.
FName Field private
FOwner Field private
FreeNotification Method public Ask the component to notify called when it is being destroyed.
FreeOnRelease Method public Part of the IVCLComObject interface.
FTag Field private
FVCLComObject Field private
GetChildOwner Method protected Returns the owner of any children.
GetChildParent Method protected Returns the parent of any children.
GetChildren Method protected Must be overridden by descendants to return all child components that must be streamed.
GetComObject Method private
GetComponent Method private
GetComponentCount Method private
GetComponentIndex Method private
GetEnumerator Method public Create an IEnumerator instance
GetIDsOfNames Method protected
GetNamePath Method public Returns the name path of this component.
GetOwner Method protected Returns the owner of this component.
GetParentComponent Method public Returns the parent component.
GetTypeInfo Method protected
GetTypeInfoCount Method protected
HasParent Method public Does the component have a parent ?
iicrGetComponent Method protected
Insert Method private
InsertComponent Method public Insert the given component in the list of owned components.
Invoke Method protected
IsImplementorOf Method public Checks if the current component is the implementor of the interface
Loaded Method protected Called when the component has finished loading.
Loading Method protected
Name Property published Name of the component.
Notification Method protected Called by components that are freed and which received a FreeNotification.
Owner Property public Owner of this component.
PaletteCreated Method protected
QueryInterface Method protected
ReadLeft Method private
ReadState Method protected Read the component's state from a stream.
ReadTop Method private
ReferenceInterface Method public Interface implementation of Notification
Remove Method private
RemoveComponent Method public Remove the given component from the list of owned components.
RemoveFreeNotification Method public Remove a component from the Free Notification list.
RemoveNotification Method private
SafeCallException Method public Part of the IVCLComObject Interface.
SetAncestor Method protected Sets the csAncestor state of the component.
SetChildOrder Method protected Determines the order in which children are streamed/created.
SetComponentIndex Method private
SetDesigning Method protected Sets the csDesigning state of the component.
SetDesignInstance Method protected
SetInline Method protected
SetName Method protected Write handler for Name property.
SetParentComponent Method protected Set the parent component.
SetReference Method private
SetSubComponent Method public Sets the csSubComponent style.
Tag Property published Tag value of the component.
UpdateAction Method public Updates the state of an action.
Updated Method protected Ends the csUpdating state.
UpdateRegistry Method protected For compatibility only.
Updating Method protected Sets the state to csUpdating
ValidateContainer Method protected ??
ValidateInsert Method protected Called when an insert must be validated.
ValidateRename Method protected Called when a name change must be validated
VCLComObject Property public Not implemented.
WriteLeft Method private
WriteState Method public Writes the component to a stream.
WriteTop Method private
_AddRef Method protected
_Release Method protected

Inheritance

Class Description
TComponent(IUnknown, IInterfaceComponentReference) Base class for all components that need owner-owned functionality.