构成Delphi工程的文件:窗体文件(.dfm)
窗体文件(.dfm)
窗体文件的扩展名为.dfm,是窗体或数据模块的文件,并且与单元文件相关联。窗体文件为脚本化的文本文件,其中定义了一些资源,使得窗体和数据模块能够存储对象的可视化外观。窗体是TForm的子类,数据模块TDataModule 的子类,两者都定义在Forms.pas 单元中。
如果需要查看窗体文件的内容,可以在窗体上单击鼠标右键选择“View as Text”菜单项,以下代码就是本章3.1 节中的资源脚本:
object Form1: TForm1
Left = 200
Top = 120
Width = 350
Height = 200
Caption = ’欢迎使用Delphi 7’
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = ’MS Sans Serif’
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 74
Top = 71
Width = 75
Height = 25
Caption = ’欢迎(&W)’
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 193
Top = 71
Width = 75
Height = 25
Caption = ’退出(&X)’
TabOrder = 1
OnClick = Button2Click
end
end