Dan*_*nny 6 delphi height client properties dfm
我的Delphi程序构建和编译很好,但是一旦它在调试模式下运行,我得到以下错误;
属性ClientHeight不存在
在查看了所有.DFM文件源之后,每种形式的代码都在那里;
ClientHeight = 111
我不明白我哪里出错了?
您的表单将使用较新版本的Delphi保存.遗憾的是,您需要在IDE中打开每个表单并再次保存以清除新属性.有一个工具可以帮助您调用DFMCheck(http://andy.jgknet.de/blog/ide-tools/dfmcheck/).这是一个附加内容,它将遍历您的所有表单,并告诉您有关表单的任何问题,这些问题只会在运行时显示.
你看到问题的原因是这个.Delphi使用所有属性保存表单.它使用流式传输在运行时加载表单.当它尝试加载具有不存在的属性的表单时,您将收到类似这样的错误,因为当该属性不存在时,流系统正在尝试在组件上设置属性.
小智 7
I know this is old thread, but hopefully this will help others that has this problem.
In cases like this where your class inheriteds from other and you know the properties are there, just re-publish them .Add a published section and add them again for example:
published
property ClientWidth;
property ClientHeight;
Run Code Online (Sandbox Code Playgroud)
This then forces the compiler to compile these typeinfo for parts where the parents classes might have forward declarations and thus , resolve your issue. Hope it helps somebody, took me 3 days to get to the solution eventually.
在使用 FMX 框架的现代 Delphi(例如 Rio 10.3)中也会发生同样的错误。经过一番调查,发现是由调整 TFrame 继承引起的。下面的例子:
type
// Declaration of custom type
TFrameEx = class(TFrame) .. {here I override a couple of methods} end;
// Causes a bug (described below)
TMyFrame = class(TFrameEx)
// Works fine
TMyFrame = class(TFrame)
Run Code Online (Sandbox Code Playgroud)
说明:
由于类型改变,Delphi 无法在 FMX 和 VCL 之间正确选择 TMyFrame 类型。因此,当在 IDE 中打开 TMyFrame 时,它会要求去除 FMX 属性(在 VCL 中不存在,例如 Size.Width)并添加 VCL 属性(例如 ClientWidth)。保存后,这会使 TMyFrame 出错 - 它会在初始化时在运行时显示“Property ClientHeight does not Exist”错误。