Create a delphi application from a dfm-file.

Posted on 2010-01-05
Last Modified: 2012-05-08

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

Question by:peterkiers
    LVL 13

    Accepted Solution

    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.
    LVL 13

    Expert Comment

    view =they
    LVL 25

    Assisted Solution

    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
    LVL 1

    Author Comment


    LVL 25

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now