简体   繁体   English

DFM 文件中的属性顺序是否重要?

[英]Does the order of properties in DFM file matter?

Could a not-standard order of the properties cause any problem?不标准的属性顺序会导致任何问题吗?

For example, the IDE stores a TButton component in the DFM file as follows:例如IDE在DFM文件中存储了一个TButton组件如下:

  object Button1: TButton
    Left = 288
    Top = 160
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end

If I manually change the order of the properties, could this cause any problem?如果我手动更改属性的顺序,这会导致任何问题吗?

  object Button1: TButton     
    OnClick = Button1Click
    Left = 288
    Top = 160
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
  end

There seem to be cases where the order actually matters!似乎有些情况下顺序实际上很重要!

For examples see the comments in the published section of TStandardColorMap, TActionManager, TActionClientItem, TTabControl, TTreeView, TMonthCalendar, TDateTimePicker and TComboBoxEx (to just name a few from Vcl), where the order of published properties is relevant.例如,请参阅 TStandardColorMap、TActionManager、TActionClientItem、TTabControl、TTreeView、TMonthCalendar、TDateTimePicker 和 TComboBoxEx(仅举几例来自 Vcl)的已发布部分中的注释,其中发布属性的顺序是相关的。

As the order of properties in the DFM determines the order the published properties are set, any other order may affect the values of the properties after reading a component from the DFM.由于 DFM 中的属性顺序决定了发布属性的设置顺序,因此任何其他顺序都可能在从 DFM 读取组件后影响属性值。

The fix-up mechanism mentioned by MartynA in another answer is not used for these sort of properties. MartynA 在另一个答案中提到的修复机制不适用于此类属性。

It makes no difference afaik.这没有什么区别。

The TReader class is responsible for handling the reading of component properties from the DFM stream. TReader class 负责处理从 DFM stream 读取组件属性。 This operates by creating a "fix-up list" of property values read from the stream, which is used, after the entire component has been read in, to set the component's properties.这是通过创建从 stream 读取的属性值的“修复列表”来操作的,在读入整个组件后,该列表用于设置组件的属性。 See the Streaming chapter in Delphi Component Design by Danny Thorpe (ISBN 0-201-46136-6) for much fuller details any why it was designed the way it is.请参阅 Danny Thorpe 编写的 Delphi 组件设计 (ISBN 0-201-46136-6) 中的流式传输章节,了解更多详细信息,了解为什么要按这种方式设计。

I see Uwe Raabe has added an answer, and he's usually right ime.我看到 Uwe Raabe 添加了一个答案,而且他通常是对的。

As far as I know order of properties in DFM file doesn't matter.据我所知,DFM 文件中的属性顺序并不重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM