John86a
asked on
[Delphi 7] Lost .dfm - Possible to recreate them with .pas ?
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!
Thank you very much!
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
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
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;
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
This gives a good explanation of how to get your dfm file
http://www.delphifaq.com/faq/delphi/delphi_ide/f168.shtml
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.
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@epasquier
You hit the nail in the head, I can't believe i had forgotten about XN resource editor
You hit the nail in the head, I can't believe i had forgotten about XN resource editor
ASKER
Awesome, thanks guys, worked perfectly.
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