System.Classes.InitInheritedComponent

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function InitInheritedComponent(Instance: TComponent; RootAncestor: TClass): Boolean;

C++

extern DELPHI_PACKAGE bool __fastcall InitInheritedComponent(TComponent* Instance, System::TClass RootAncestor);

Properties

Type Visibility Source Unit Parent
function public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Description

Initializes streaming of a form file for an inherited root class.

Call InitInheritedComponent from the constructor of a root class to start streaming in of information in the associated form file.

Instance is the object being instantiated.

RootAncestor is the base root class of which Instance may represent a descendant. This class must be a root class, meaning a class such as TCustomForm, TFrame, or TDataModule, which is the starting point of the streaming process (the component associated with the form file).

InitInheritedComponent returns true if the form file was successfully streamed in, false otherwise.

The call to InitInheritedComponent is only required for descendant classes of the root class, and must follow the construction of the object instance except for streaming in of persistent properties in the form file. The following Delphi and C++ code samples show typical root class contstructors:

constructor TMyRootClass.Create(AOwner: TComponent);
begin
  inherited Create(AOwner); { first construct an object instance }
  if (ClassType <> TMyRootClass) and not (csDesigning in ComponentState) then
  begin
    if not InitInheritedComponent(Self, TMyRootClass) then
      raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);
  end;
end;
void TMyRootClass.TMyRootClass(TComponent AOwner)
{
  if ( (ClassType != TMyRootClass) && !(ComponentState.Contains(csDesigning))
  {
    if !(InitInheritedComponent(this, TMyRootClass))
      throw EResNotFound(SResNotFound, TVarRec theClassName[] = {ClassName}, 1);
  }
}

See Also