Delphi: frame properties do not update when I expect them to (they get stuck)

和自甴很熟 提交于 2019-12-12 08:15:08

问题


I have a frame on a form. When I change the frame (add/delete buttons, labels) no changes appear on the form or controls have other positions in the form that in the frame. If to delete the frame from the form and add it again -> Ok.

Why? As I remember there were no problems in Delphi 2010 (now-Delphi XE).

Thanks.


回答1:


So you had created a frame, and then dropped an instance of it on another form, and the problem is that later changes made to the original frame are not immediately shown until you delete the instance and re-drop it?

You don't need to delete the frame, just right click and select the controls you want to have their properties come from their master (original frame) properties, and click Revert to inherited. Oddly enough, Select All doesn't work in frames.

This is one of the reasons I avoid frames. I wish frames had a "don't allow customization" property (AllowCustom=false) that would prevent any designtime DFM conflicts by not allowing frames to have this weird double-sets-of-properties.

Another way to normalize your frames is to right click and view the form as text, and reduce your frame to this:

 inline Frame61: TMyFrame61
    Left = 0
    Top = 0
    Width = 500
    Height = 500
    Align = alNone
    TabOrder = 0
    ExplicitLeft = 31
    ExplicitTop = 33
  end

Now it contains no overridden properties at all.

If I drag one of the controls somewhere else (even accidentally), the following happens in the DFM where the Frame has been dropped:

 inline Frame61: TMyFrame6
    Left = 0
    Top = 0
    Width = 500
    Height = 500
    Align = alNone
    TabOrder = 0
    ExplicitWidth = 527
    ExplicitHeight = 337
    inherited Edit2: TEdit
      Left = 19
      Top = 77
      ExplicitLeft = 19
      ExplicitTop = 77
    end   
  end

These extra bits of stuff in the DFM interfere with changes that you made at the other level. Normally adding extra controls and deleting controls is no problem (extra controls should show up when added, automatically, and deleted controls should go away), but with the effects of positioning problems (control overlaps/etc) the effect can be that you don't see the change until later.



来源:https://stackoverflow.com/questions/6946943/delphi-frame-properties-do-not-update-when-i-expect-them-to-they-get-stuck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!