Inheriting a Custom TFrame
Antoine Borg - Lasercomb Malta Ltd
borg@melita.net
Wed, 17 May 2000 13:54:33 +0200
--------------------------------------------------------------------------------
Hi all ...
I'm not sure if anyone has seen this before but I thought I'd post it for
your information:
I have a custom frame (derived from TFrame) which I am using as a base class
for several other frames in my project. When I wanted to create a new frame
from my TBaseFrame, I created a new frame through the IDE and then changed
the interface section from:
TFrame1 = class (TFrame)
to
TFrame1 = class (TBaseFrame)
This caused me several problems because the IDE decided that it should write
out some properties to the dfm file which don't exist for a frame. The
properties it wrote in were OldCreateOrder, PixelsPerInch and TextHeight.
This caused a problem when I ran my program; a TReader class raised an
exception claiming that these properties do not exist in frames. I traced
it back to the dfm file and could not figure out why the IDE was insisting
on writing these properties out.
Then I created a second frame from TBaseFrame but using the New dialog box
instead - I selected the project tab, chose "Inherit" and selected the
TBaseFrame which was in my project. This did not cause any problems and so
I compared the dfm files.
It turns out that the dfm files for frames are slightly different: they
start off
inherited GroupFrame: TGroupFrame
instead of
object GroupFrame: TGroupFrame
I changed "object" to "inherited" and had no more problems.
I thought you might like to know - just in case you ever get a similar
problem. I would be interested in knowing what the IDE thought it was doing
though - did it think it had a form instead of a frame? If so, does this
mean that the IDE writes properties to the dfm file even if they are not in
the Object Inspector? I thought that it only wrote properties that the
developer modified through the OI ... any thoughts?
Regards
Antoine
Bookmarks