dfm Files

Top  Previous  Next

Delphi projects > dfm Files

To reuse Delphi form files, that are files with the extension "dfm", you have to create a C++Builder project manually like your Delphi project, but with empty forms and without user code. It is important however, that the forms in this dummy project get the exactly the same names as the according Delphi forms and also the the corresponding units have to have identical names. The tool MainFormExchange assists the following steps.

 

There are several ways to accomplish this task. Below is a description how to proceed, if the C++Builder project shall be placed into the same folder as the existing Delphi project.

 

 

Create a new C++Builder VCL application. You have to choose a configuration that compiles C++11 code.

 

 

 

Let's assume that the name of your Delphi main form is "MainForm", then rename the automatically created main form to this name.

 

 

MainForm

 

 

Now you can save the project into the same folder where your Delphi project is saved. At first you will be prompted to enter the name of the main unit. Here you have to choose the same name as the Delphi main form has. Of course it will have the "cpp" extension instead of the original "pas" extension. Let's assume the original file calls "Main.pas":

 

MainformSaveAs

 

 

Now it is important, that you rename your original form file "Main.dfm" to another temporary name. If you don't do that, you will be prompted to overwrite the original file. But we still need it.

 

Next you will be prompted to choose a name for the precompiled header file. It is recommended to take the name of the Delphi project file plus PCH1.h

 

<Delphi projectname>PCH<n>.h

 

Finally you have to choose a name for the C++Builder project. Again it is recommended to take the name of your Delphi project.

 

<Delphi projectname>.cbproj

 

 

Now you have to close the C++Builder project, delete the automatically created main form file "Main.dfm" and rename the original Delphi main form back to "Main.dfm". This is also a good moment to overwrite the C++ files that were created by the C++Builder IDE with the files of the Delphi2Cpp II translation.

 

Now you can reopen the C++Builder project. If all components, that you used in the Delphi main form are installed in C++Builder too, the form that you know from your Delphi project is shown identically in C++Builder now.

 

If you used Components, which are not installed in C++Builder, you will get according error messages. You either can ignore them with the risk that something gets lost on your form or you can cancel and install the needed components first.

 

 

 

 

 



This page belongs to the DelphiXE2Cpp11 Documentation

DelphiXE2Cpp11 home  Content