TFrame Displaying as TForm in Designer

I came across an interesting quirk in the Delphi 2010 IDE today.  I was working in a project that uses a lot of TFrame components.  To make life easy on myself, or so I thought, I created a custom TFrame descendant and used that in place of the default TFrame.

Everything was working well until I displayed one of the frames as text, made some silly change and then redisplayed the frame’s visual designer.  At this point, the IDE started treating my TFrame as a TForm.  It displayed as a TForm in the visual designer, all of TForm’s properties appeared in the object inspector, all of TForm’s properties were being saved in the .DFM file.  I didn’t notice this right away.  Not until I recompiled everything and tried to run the application.  At this point I started to get ‘ClientHeight property not found’ errors when I tried to instantiate the TFrame.

This little gotcha cost me most of an afternoon.  I guess the rule is:

If you are designing a TFrame descendant use the visual designer only.  Do not try to edit the .DFM file as text.

Leave a Reply