Solved

[Delphi 7] Lost .dfm - Possible to recreate them with .pas ?

Posted on 2010-11-22
9
1,181 Views
Last Modified: 2012-05-10
Hello people, I have a huge project, and somewhere along the way the .dfm file of the main login window got lost, leaving me with the .pas file only. Everything compiles fine and dandy, but I wanted to edit the login window, is it possible to recreate it somehow from the .pas file?

Thank you very much!
0
Comment
Question by:John86a
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34193705
You can go through the declared components in the .pas and drop them one by one onto the form.
However, you'll quickly find that
you don't know which panel contains what textbox
it says nothing about stored settings, e.g. textbox1.text is stored in dfm, tpanel.color etc

This is almost a lost cause - however, luckily there are some decompilers that can recreate .dfm files perfectly.  like dede (google).  that is assuming you have a .exe around compiled from that .dfm
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34193706
You can go through the declared components in the .pas and drop them one by one onto the form.
However, you'll quickly find that
you don't know which panel contains what textbox
it says nothing about stored settings, e.g. textbox1.text is stored in dfm, tpanel.color etc

This is almost a lost cause - however, luckily there are some decompilers that can recreate .dfm files perfectly.  like dede (google).  that is assuming you have a .exe around compiled from that .dfm
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34193753
If you mean automatically, I doubt that's to be even possible.
You have to read the Form Class and manually drop the declared components and adjust the properties as needed. Even manually it might be challenging issue.

And I say that simply because most (actually it's all) of the details of the components are missing specially the visible components, for instance, the location (top, left, width, height and caption if any. May be that's a simple to overcome for simple components, but if there are high features components that would be impossible such as database components and the have-a-lot-to-configure components.

For example the following Form Class has the attached DFM file below and that's all with default properties and if you specify anything that won't be indicated in the pas file.

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    QuickRep1: TQuickRep;
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

object Form1: TForm1
  Left = 192
  Top = 114
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Scaled = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 80
    Top = 40
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
  object Label2: TLabel
    Left = 80
    Top = 64
    Width = 32
    Height = 13
    Caption = 'Label2'
  end
  object Edit1: TEdit
    Left = 120
    Top = 40
    Width = 121
    Height = 21
    TabOrder = 0
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 120
    Top = 64
    Width = 121
    Height = 21
    TabOrder = 1
    Text = 'Edit2'
  end
  object Button1: TButton
    Left = 136
    Top = 96
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 2
  end
  object Button2: TButton
    Left = 136
    Top = 128
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 3
  end
  object QuickRep1: TQuickRep
    Left = 264
    Top = 56
    Width = 794
    Height = 1123
    Frame.Color = clBlack
    Frame.DrawTop = False
    Frame.DrawBottom = False
    Frame.DrawLeft = False
    Frame.DrawRight = False
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'Arial'
    Font.Style = []
    Functions.Strings = (
      'PAGENUMBER'
      'COLUMNNUMBER'
      'REPORTTITLE')
    Functions.DATA = (
      '0'
      '0'
      #39#39)
    Options = [FirstPageHeader, LastPageFooter]
    Page.Columns = 1
    Page.Orientation = poPortrait
    Page.PaperSize = A4
    Page.Values = (
      100.000000000000000000
      2970.000000000000000000
      100.000000000000000000
      2100.000000000000000000
      100.000000000000000000
      100.000000000000000000
      0.000000000000000000)
    PrinterSettings.Copies = 1
    PrinterSettings.Duplex = False
    PrinterSettings.FirstPage = 0
    PrinterSettings.LastPage = 0
    PrinterSettings.OutputBin = Auto
    PrintIfEmpty = True
    SnapToGrid = True
    Units = MM
    Zoom = 100
  end
  object ADOConnection1: TADOConnection
    Left = 72
    Top = 120
  end
  object ADOQuery1: TADOQuery
    Parameters = <>
    Left = 88
    Top = 184
  end
end

Open in new window

0
 
LVL 32

Accepted Solution

by:
ewangoya earned 250 total points
ID: 34193882
Of course you can get back your dfm from the exe file
dfm is just a resource stored in the exe

Use a resource editor to open the exe and you will see the dfm file in RCData

You can even use the resource explorer demo program that comes with delphi
0
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

 
LVL 32

Expert Comment

by:ewangoya
ID: 34193914
Ok, here's the article I was looking for, just couldn't remember where it was
This gives a good explanation of how to get your dfm file

http://www.delphifaq.com/faq/delphi/delphi_ide/f168.shtml
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34194473
I was referring to recovering DFM from PAS file, as per the original question: "is it possible to recreate it somehow from the .pas file?"

Recovering from the EXE:
Resource Editors generate raw data and I am not sure if they provide easy-to-use data but definitely is useful.

The best to use is either IDR ( http://kpnc.org/idr32/en ) or, as mentioned by cyberkiwi, Dede ( http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/DeDe.shtml ), and there are plenty to use but nothing is 100% perfect.
0
 
LVL 25

Assisted Solution

by:epasquier
epasquier earned 250 total points
ID: 34195904
Use XN Resource Editor !

THAT is THE tool every delphi developpeur should have close to hand. Among other things, it can recover and even edit DFM files embedded in the executable.
And it's free
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm
XNResEdit.gif
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 34196720
@epasquier

You hit the nail in the head, I can't believe i had forgotten about XN resource editor
0
 

Author Closing Comment

by:John86a
ID: 34201898
Awesome, thanks guys, worked perfectly.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
only14 challenge 19 64
Choosing the right language for new project 8 58
Magic Software info 18 105
Problem to open Excel file 15 44
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

746 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

11 Experts available now in Live!

Get 1:1 Help Now