7
votes

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?

5
similar issue still persists today (2018). Delphi IDE is very buggy: stackoverflow.com/questions/49358639/…Z80

5 Answers

7
votes

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.

7
votes

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.

5
votes

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.

0
votes

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.

0
votes

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