Top  Previous  Next


Delphi units, which either define Delphi VCL forms or frames are associated with form modules. These form modules are files with the extension dfm. The code in a DFM-files determines how forms or frames are constructed by means of the members of the visual component library (VCL). The code in DFM-files is not Object Pascal, but describes graphical interfaces in an abbreviated way. Delphi2Cpp can parse the DFM-code and and translate it into C++ code to create the form at runtime. Therefore the option to convert the DFM code has to be enabled.


Per default all lines of the DFM code are converted to C++ assignment statements. However, when the Delphi compiler reads the DFM code, more can actually happen than simple assignments. Delphi2Cpp tries to reproduce the complex loading process in the most intuitively simple way possible when dynamically creating the components at runtime. To reproduce the additional effects just mentioned, Delphi2Cpp uses some special routines. Instead of assigning values ​​directly to properties, they are passed as arguments to the routines in which additional actions can then be carried out. Based on some exemplary examples, there are a number of such predefined routines. More routines can be defined by the user if necessary. 


The names of these routines are formed in a systematic manner from the types and properties involved. The routines themselves should be declared and defined in the file d2c_dfm.h/d2c_dfm.cpp. In order to trigger the output of these routines into the generated code, Delphi2Cpp must be configured accordingly..There is a dialog with the label DFM Conversion, in which the list of types and properties for which such special assignment routines should be issued will be defined.


The code will be written into the constructor of the form or into the constructor of a frame. If the components are created dynamically at runtime the form file is not needed any more.




This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content