In the application of Delphi development, each form has a corresponding form file (. dfm) that records the properties of the form and the properties of all the controls on the form so that the form can be rebuilt exactly after the form is closed. Almost all Delphi reference books do not mention the details of the document, occasionally mentioned, also all generalities, because the form file is a binary file, only in the editing environment provided by Delphi can see its true nature, the operation of which may have unpredictable errors; , there is no need to modify it. This article is about the same as the form file.
To take advantage of a form file, you must first understand the structure of that type of file. Form file structure is very simple, friends can generate a form, casually put some controls, save the Unit1.dfm file opened, you can see the form file is the keyword "object" and "end" of the code snippet, the basic structure is as follows:
object 控件名 :类名
属性1 =属性值
属性2 =属性值
…
end
and supports nesting. Delphi records the properties of the control, only the modified properties, for example, for example, the default description of a Label control (LABEL1) is as follows:
object Label1: TLabel
Left = 256
Top = 80
Width = 32
Height = 13
Caption = Label1
End
The five attributes of the record vary with the location and order of the developer's drag-and-drop, and the other attributes are default values because they have not been modified, so you do not have to record them.
The form file is ordered, and its orderly performance is as follows:
object 窗体名:Tform
窗体属性1=属性值
窗体属性2=属性值
。。。 。。。
// 以下是TgraphControl类型的控件
object 控件名:类名
控件属性1=属性值
控件属性2=属性值
。。。 。。。
end
object 控件名:类名
控件属性1=属性值
控件属性2=属性值
。。。 。。。
end
。。。 。。。
// 以下是TwinControl类型的控件
object 控件名:类名
控件属性1=属性值
控件属性2=属性值
。。。 。。。
end
object 控件名:类名
控件属性1=属性值
控件属性2=属性值
。。。 。。。
end
。。。 。。。
// 以下是其它类型的控件
object 控件名:类名
控件属性1=属性值
控件属性2=属性值
。。。 。。。
end
。。。 。。。
end