Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: 'Property ClientHeight does Not Exist'

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?

like image 902
Danny Avatar asked Mar 04 '14 19:03

Danny


3 Answers

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.

like image 82
Graymatter Avatar answered Oct 18 '22 07:10

Graymatter


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.

like image 7
Johannes Avatar answered Oct 18 '22 06:10

Johannes


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.

like image 5
Kromster Avatar answered Oct 18 '22 06:10

Kromster