Is there a Delphi option to 'lock' the design (layout) of a form against accidental changes?

大兔子大兔子 提交于 2019-11-29 10:20:01

The only thing I can think of (other than the read-only/VCS options you mentioned) is the Edit menu's Lock Controls option. This sets a flag that prevents controls from being moved around. I'm not sure how much good it would actually do, as I've never tried it; I just know it's there.

Helo

I am pretty sure that Delphi has no such a thing. I have been searching for a solution to this problem as well.

But, theres one thing you can do: You can write your own Delphi addon using OTA (Open Tools API). I know that there are a few classes which are able to notify you when something are about to be saved. You can intercept this event and decide if you wanna save it (in your case, if it is a DFM).

BTW, if you have plans to do such component, tell me. :)

EDIT:

I have found a piece of code that may help you. Extracted from http://www.gexperts.org/otafaq.html

  TMyFormNotifier = class(TNotifierObject, IOTANotifier, IOTAFormNotifier)
  protected
     procedure FormActivated;
     procedure FormSaving;
     procedure ComponentRenamed(ComponentHandle: TOTAHandle; const OldName, NewName: string);
  end;

In design time there is Edit->Lock Control.

LE: this is only for resizing/repositioning the controls on the forms. Concerning the ObjectInspector I don't know if there is anything that can 'lock' the values set there(so the developer can not change them).

Basically, no. Aside from the f'ing (pardon my french) explicit size and position properties which IMO never should have been in the .dfm, there are some third party components will change stuff just by you viewing the form. F.x. TMS components will update a version number even if you didn't change a thing since the previous version of their components.

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