Reputation: 8043
In a TForm
descendant with several levels of inheritance.
... TForm -> TForm1 -> TForm2 -> TForm3
Each level, from the DFM designer, modifies the form's Caption
(i.e: 'A' for TForm1
, 'B' for TForm2
and 'C' for TForm3
).
At runtime, for a TForm3
form, I would like to save the initial Caption
's value ('C') in a private form's field (i.e: FInitialCaption : string
).
I thought to use the Loaded
procedure but the documentation states:
Warning: Loaded may be called multiple times on inherited forms. It is called every time a level of inheritance is streamed in. Do not allocate memory in an overridden Loaded method without first checking that the memory has not been allocated in a previous call.
In this example case, I'm sure it will not cause any appreciable problem, but I'm wondering which is the right place for reacting to the DFM settings once for all, avoiding useless code execution?
Upvotes: 0
Views: 144
Reputation: 612804
Capture this in an overridden constructor, or an OnCreate
event handler.
Personally I would use a constructor for this since I see little point to the OnCreate
and OnDestroy
events.
Upvotes: 4