Create a delphi application from a dfm-file.


Is it possible to create a delphi-application from a dfm-file.

Who is Participating?
rfwoolfConnect With a Mentor Commented:
Is this a delphi-generated dfm file?
View contain a list of objects and their properties on a form, and the names of procedures attached to events of objects on the form, but, they fail to give the procedures themselves, for that you use a .pas file (unit file).
In other words your dfm will give you an idea of what procedures you need and what the user sees, but  You will need to rewrite all the code.
view =they
Emmanuel PASQUIERConnect With a Mentor Freelance Project ManagerCommented:
a dfm file contains all the components of a form with names and types, hieriarchy and parameters.
What you could do from only the dfm is recreate the form .pas file so that when you open it in the delphi IDE it would look the same as the original form, but you will have no event codes.

I don't think there is a tool to do so, but basically all you have to do is creating a new form, and in a standard text editor you add all components declaration in the first section of the form class (the one that is updated automatically by the IDE when you add components) to match all those that are in the dfm, but in a hierarchical way. Then you replace the automatically generated dfm with the old one, and open the modified .pas with the IDE
peterkiersAuthor Commented:

Emmanuel PASQUIERFreelance Project ManagerCommented:
about the events now, in the dfm they are linked with the functions like
OnCreate = FormCreate

You obviously don't have the FormCreate code. So if you leave these on...=... lines the IDE will complain.
Easiest way to move another step forward is to remove all these lines in the DFM file but with keeping elsewhere all events names and objects that triggers them, so that you can easily recreate the skelettons of these functions with the IDE by selecting all the related components manually and double click on each events.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.