System.Classes.InitInheritedComponent

Aus RAD Studio API Documentation
Wechseln zu: Navigation, Suche

Delphi

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

C++

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

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
function public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Beschreibung

Initialisiert für eine geerbte Stammklasse das Streamen einer Formulardatei.

Durch einen Aufruf von InitInheritedComponent im Konstruktor einer Stammklasse können Sie das Streamen von Informationen in der zugehören Formulardatei einleiten.

Instance ist das Objekt, das instantiiert wird.

RootAncestor ist die Basis-Stammklasse, von der Instance abgeleitet ist. Es muss sich dabei um die Stammklasse handeln (z.B. TCustomForm, TFrame oder TDataModule), die den Ausgangspunkt des Stream-Vorgangs darstellt (also die mit der Formulardatei verbundene Komponente).

Wenn das Streamen der Formulardatei erfolgreich war, gibt InitInheritedComponent true zurück, andernfalls false.

Ein Aufruf von InitInheritedComponent ist nur für abgeleitete Klassen einer Stammklasse erforderlich und muss auf die Erstellung der Objektinstanz folgen (dies gilt nicht für das Streamen von persistenten Eigenschaften in der Formulardatei). Das folgende Beispiel für Delphi und C++ zeigt typische Konstruktoren von Stammklassen:

constructor TMyRootClass.Create(AOwner: TComponent);

begin inherited Create(AOwner); { zuerst eine Objektinstanz erstellen } 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); } }

Siehe auch