[Lazarus] Making a form read-only

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Dec 27 22:53:20 CET 2012


Mark Morgan Lloyd schrieb:
> Mattias Gaertner wrote:
>> Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> hat am 27. 


>> Maybe the source editor of the lfm should be made readonly while the 
>> form is
>> open, although I found the current state useful a few times and no one 
>> has
>> complained yet.
> 
> Maybe. I think some way of locking the form down would be useful, as 
> supported by (at least some versions of) Delphi. I'm not so much 
> complaining now that I've a better understanding of why I was seeing 
> problems... except that I think setting one representation of a unit or 
> form r/o and still being able to change it via other representations or 
> windows is undesirable.

+1


>> A form can not really be made readonly because some things are not 
>> controlled by
>> the IDE. For example the window manager and theme changes. And some 
>> things have
>> cross-form side effects. For example editing the ancestor of a form.
>> Maybe a form can be marked as 'ask before saving changes'. But I 
>> wonder if this
>> setting should really be per-form or if it would be better defined in
>> categories, like all forms in a directory, or forms not belonging to the
>> project.

My recent (bad) experience from working with D5 is, that the form layout 
should be protected better against inadvertent changes, at least in 
Lazarus. When my VM window was shrunk recently, all open forms were 
resized, even if only the .pas file was open, and this change made them 
unusable at runtime :-(

I'd really like an *option* (project setting!) to open a project with 
all forms locked. Then it would be possible to e.g. fix bugs in a 
project without risking changes to the DFM/LFM files. In a long-term 
(commercial...) project *no* single developer, and *no* IDE, should be 
allowed to change the *appearance* of the program accidentally.

In the best case it should be possible to preserve all control and form 
*sizes and positions*, while changes to control properties (list styles, 
handlers...), using OI and property editors, should be allowed. 
Eventually a project (or form) layout file can be used, or another set 
of form and control bounds, allowing to restore the actual bounds to 
exactly these values. Something like "Save/Restore Layout" (or 
Appearance) menu items. In a business project the forms' layout should 
be password protected, so that only selected developers can change the 
appearance of a released program *willingly*; in fact every make/build 
should use the acknowledged project size/position values, regardless of 
eventual changes to individual forms.


> But while things like size changes apply to the content of a form, theme 
> changes wouldn't- only to its presentation during design.

+1

> I accept that I'm very much in a minority here.

I'm not so sure. I don't think that the silent majority would have 
objections against better protection of a project's appearance, against 
inadvertent or automatic changes.

> I wouldn't really have 
> noticed anything if I didn't have a very small number of programs that 
> I'm trying to keep working from everything like GTK1 and NT4 onwards: in 
> general experience suggests that that sort of effort is more hassle than 
> it's worth.

There exist many more scenarios, where changes to the layout of a 
program GUI are undesireable, e.g. when a developer is hired to work on 
an existing business program. I consider to implement a tool for 
beforementioned save/restore functionality, usable with Delphi projects. 
I really don't want to be guilty when a customer cannot use a program 
any more, because some non-resizeable forms have been resized by some 
accident on my machine :-(

DoDi





More information about the Lazarus mailing list