Delphi: 'Property ClientHeight does Not Exist'
Asked Answered
E

5

8

My Delphi program builds and compiles fine, however as soon as it is run in the debug mode, I get the following error;

Property ClientHeight does Not Exist

After looking through all of the .DFM file sources, in every form the code is there which is;

ClientHeight = 111

I'm not understanding where I go wrong here?

Elyse answered 4/3, 2014 at 19:32 Comment(1)
similar issue still persists today (2018). Delphi IDE is very buggy: #49359139Cabalism
E
8

Your forms would have been saved with a newer version of Delphi. Unfortunately you will need to open each form in the IDE and save it again to clear the newer properties. There is a tool that can help you called DFMCheck (http://andy.jgknet.de/blog/ide-tools/dfmcheck/). This is an add on that will go through all of your forms and tell you about any problems with the forms that will only show up at runtime.

The reason why you are seeing the problem is this. Delphi saves the forms with all of the properties. It uses streaming to load the forms at runtime. When it tries to load a form with properties that don't exist then you will get an error like this as the streaming system is trying to set a property on a component when the property doesn't exist.

Edris answered 4/3, 2014 at 19:41 Comment(4)
Thank you very much for the helpful answer! I will have to give this a try on Thursday when I'm using the development machine again.Elyse
If you are using different Delphi versions on a regular basis and have one of them saving ClientHeight and ClientWidth you might consider DDevExtensions (from the same site as DFMCheck) where you can disable saving these properties in the dfm to be compatible with older versions.Knipe
@Edris I've tried saving the forms again and even using DFMCheck, however I'm still receiving the error. It's a plugin I'm developing for a program called UCWin/Road 6. When I debug within Delphi, ucwinroad crashes because of the plugin with no messages. However if I build the plugin and then import it into ucwinroad, I receive an the error stating TCPServerPlugin.ClientHeight: Property ClientHeight does not exist. I'm not sure how to proceed with this.Elyse
@Elyse Which version of Delphi do you have?Edris
S
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;

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.

Swerve answered 6/2, 2015 at 11:44 Comment(0)
K
5

Same bug happens in modern Delphi (e.g. Rio 10.3) with FMX frames. After some investigation it revealed to be caused by tweaking TFrame inheritance. Example below:

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)

Explanation:
Due to changed type, Delphi was unable to correctly choose TMyFrame type between FMX and VCL. So when the TMyFrame was opened in IDE it would ask to strip out FMX properties (non-existent in VCL, e.g. Size.Width) and add VCL properties (e.g. ClientWidth). When saved, that would make the TMyFrame buggy - it would show the "Property ClientHeight does Not Exist" error in runtime upon init.

Kahl answered 5/2, 2019 at 12:49 Comment(3)
Thanks. Is there a workaround other than not deriving from TFrame subtypes?Mohur
@DavidU I haven't found any. This looks like IDE bug, so maybe it will be fixed in next version .. who knows.Kahl
Interestingly I'm getting this same error (using derived Frame classes) with C++Builder 2010, which I think predates FMX.Latarsha
D
0

Had similar bug. First you need a dfm file for your frame. When you inherit a frame, the dfm file must starts with "inherited MyFrame: TFRameEx" and NOT "object MyFrame: TFrameEx". Without the inherited, when I did it, it was adding TForm properties and in the editor the frame had TForm events, in Delphi 10.3. So delphi really needs the dfm to find the right type. If you use the ide menu, it will be done automatically. New->Others->inheritables it will create the dfm with the inherited line, create a file with {$R *.dfm} in it and a line in the project source "unitname in '......pas' {MyFrame TFrame};" Or you can do it by hand. As for the possibility of having multiple frames in the same unit, havent tested it myself but since the line is {$R *.dfm} it might be doable.

wanted it to be a comment for the solution of kromster but cant comment apparently.

Durante answered 9/1, 2021 at 10:26 Comment(0)
W
0

In my case, I was inheriting TFrame that was save in Delphi 7, and I change the .dfm to resolve.

The first line: "object" frmMain: TfrmMain

I changed to "inherited", like this: inherited frmMain: TfrmMain

What answered 10/3, 2021 at 17:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.