Solved

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

Posted on 2010-11-22
9
1,214 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

830 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