You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何OldCreateOrder属性持续自动恢复为True?

Why does OldCreateOrder keep resetting to True in my inherited Delphi service class?

Let me break down what's happening here and how to fix it:

The Root Cause

When you use the inherited keyword in your subclass's DFM file (like inherited GuardianService: TGuardianService), Delphi's Form/Component Editor has a quirk with published properties that aren't explicitly overridden in the child DFM.

OldCreateOrder is a property of TComponent with a default value of True. Even though your parent class sets it to False, the editor doesn't automatically inherit this value in the child unless you explicitly declare it in the subclass's DFM. When you open the unit, the editor checks for missing published properties and fills in the default value (True) automatically, overriding the implicit inheritance you might expect.

How to Fix It

You need to explicitly add the OldCreateOrder = False line to your subclass's DFM file, right alongside your DisplayName override:

inherited GuardianService: TGuardianService
  OldCreateOrder = False
  DisplayName = 'Guardian'
end

Once you add this explicit declaration, the editor will respect the value and stop resetting it to True when you open the unit.

If you're still seeing issues (common in older Delphi versions like Delphi 7), try editing the DFM file directly with a plain text editor, saving it, then reloading your project. This bypasses any editor-specific caching that might be causing the problem.

内容的提问来源于stack exchange,提问作者vostock

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:48:11