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

After several years of developing Delphi, I now have hundreds of forms that are used in all of our Applications. Compilation varies from Delphi 7 to XE, so one form can be opened in any IDE. The well-known addition of the Explicitxxx property after Delphi 7 has solutions that allow you to avoid accidentally acquiring a form that compilers could not previously handle (for example, Andreas DDevExtensions ), but I would like a more positive “switch” that prevented Delphi from creating or saving any form modifications in general. Period.

Of course, you can use the read-only flag, and the version control system provides additional tools, in particular, seeing that such a modification has occurred. I would really like to, but this is the {$ LockDFM} switch, which I could place in the form module, or the context menu option when viewing the form layout.

Can anyone think of a neat way to achieve this?

thanks

+7
source share
4 answers

The only thing I can remember (except for the read-only / VCS options that you mentioned) is the “Change” menu of Lock Controls . This sets a flag that prevents the controls from moving. I am not sure how good this would be, as I have never tried; I just know it there.

+6
source

Helo

I'm sure Delphi doesn't have such a thing. I also looked for a solution to this problem.

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

By the way, if you have plans to make such a component, tell me. :)

EDIT:

I found a piece of code that can 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; 
+3
source

During development, there is Edit-> Lock Control.

LE: this is only for resizing / rearranging controls on forms. As for the ObjectInspector, I don’t know if there is anything that can “block” the values ​​set there (therefore, the developer cannot change them).

+1
source

In principle, no. Besides the obvious sizes and properties of the f'ing (pardon my french) position, IMO should never have been in .dfm, there are some third-party components that will change the material simply by looking at the form. Fx TMS components will update the version number even if you have not changed a thing from the previous version of your components.

+1
source

All Articles