RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Classes.InitInheritedComponent Function

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

Pascal
function InitInheritedComponent(Instance: TComponent; RootAncestor: TClass): Boolean;
C++
Boolean InitInheritedComponent(TComponent * Instance, TClass RootAncestor);

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);
  }
}

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!