DefineProperties

Top  Previous  Next

DFM-Translator > Special assignments > DefineProperties

Unpublished data of a component can be written into a form file and read from a form file by means of the overwritten function DefineProperties. These data often concern the presentation of non-visible components at design time. Such data are not used, when the code of a DFM-file is translated to C++. Other effects of DefineProperties can be simulated in Delphi2Cpp using special assignment procedures

 

Here is a short sketch of how "DefineProperties" comes into play when creating the components: when Delphi creates a new form (TApplication.CreateForm), a TResourceStream is created in which the DFM content is read with a TReader to create the complete tree of the components on the from. Individual components are read and generated by the function:

 

function TReader.ReadComponent(Component: TComponent): TComponent;

 

In the procedure

 

procedure TReader.ReadProperty(AInstance: TPersistent);

 

first the name of the property is read and then its value. Normally, a setter method is determined here via property information (TProperty) for the property, which can be used to set the value. If this is not possible, the component method DefineProperties is called to set the value. DefineProperties has access to the internal state of the component and can manipulate it. This access cannot be fully reproduced with Delphi2cpp's simple approach of dynamically creating the components.

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content