Solved

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

Posted on 2010-11-22
9
1,250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 32

Accepted Solution

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

635 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