Delphi 是否有一个“锁定”选项?防止意外更改的表单设计(布局)?

发布于 2024-10-28 05:54:33 字数 436 浏览 1 评论 0原文

经过多年的 Delphi 开发,我现在在我们的应用程序中共享了数百个表单。编译范围从 Delphi 7 到 XE,因此一种表单可以在任何 IDE 中打开。 Delphi 7 之后添加的众所周知的 Explicitxxx 属性提供了解决方案,以避免表单意外获取早期编译器无法处理的属性(例如 Andreas 的 DDevExtensions),但我想要一个更积极的“开关”,以阻止 Delphi 进行或保存任何表单修改。时期。

当然,您可以使用只读标志,并且版本控制系统提供了额外的方法,特别是查看是否发生了此类修改。不过,我真正想要的是一个可以放入表单单元中的 {$LockDFM} 开关,或者在查看表单布局时的上下文菜单选项。

谁能想出一个巧妙的方法来实现这一目标?

谢谢

After years of Delphi development I now have hundreds of forms shared throughout our Applications. Compilation ranges from Delphi 7 through to XE, thus one form might be opened in any IDE. The well-known Explicitxxx property addition after Delphi 7 has solutions to avoid a form accidentally acquiring properties that earlier compilers can't process (e.g Andreas's DDevExtensions) but I'd like a more positive 'switch' that prevented Delphi from making or saving any form modifications at all. Period.

Of course you could use the read-only flag, and a version control system provides additional means particulay of seeing that such a modification has occured. What I'd really like though is a {$LockDFM} switch that I could put in the form's unit, or a context menu option when viewing the form layout.

Can anyone think of a neat way of achieving this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

离不开的别离 2024-11-04 05:54:34

我唯一能想到的(除了你提到的只读/VCS 选项)是“编辑”菜单的“锁定控件”选项。这会设置一个标志来防止控件移动。我不确定它实际上会有多大好处,因为我从未尝试过;我只知道它就在那里。

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.

沧桑㈠ 2024-11-04 05:54:34

Helo

我很确定 Delphi 没有这样的东西。我也一直在寻找这个问题的解决方案。

但是,您可以做一件事:您可以使用 OTA(开放工具 API)编写自己的 Delphi 插件。我知道有一些类可以在要保存某些内容时通知您。您可以拦截此事件并决定是否要保存它(在您的情况下,如果它是 DFM)。

顺便说一句,如果您有计划做这样的组件,请告诉我。 :)

编辑:

我找到了一段可能对您有帮助的代码。摘自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;

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;
迎风吟唱 2024-11-04 05:54:34

在设计时有编辑->锁定控制。

LE:这仅用于调整表单上控件的大小/位置。关于 ObjectInspector,我不知道是否有任何东西可以“锁定”那里设置的值(因此开发人员无法更改它们)。

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).

著墨染雨君画夕 2024-11-04 05:54:34

基本上,没有。除了我认为不应该出现在 .dfm 中的 f'ing(请原谅我的法语)显式大小和位置属性之外,还有一些第三方组件将通过您查看表单来更改内容。即使您自其组件的上一个版本以来没有进行任何更改,Fx TMS 组件也会更新版本号。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文