Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-22
9
Medium Priority
?
1,301 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 1000 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:Ephraim Wangoya
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 1000 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:Ephraim Wangoya
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

963 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