Hi,
Below is the definition of TComponent.ChangeName.
TComponent = ...
..
protected
procedure ChangeName(const NewName: TComponentName);
...
end;
For improved support in visual form designers [more specifically fpGUI's
Form Designer - but this applies to other form designers too], I want
Graeme Geldenhuys schreef:
Unfortunately ChangeName is not virtual, yet it is in the 'protected'
section of a class. If we are not supposed to override ChangeName, then why
is it in 'protected' section and not 'private' section of the class definition?
Obviously, so that descendants can call it
Vincent Snijders het geskryf:
>
> Obviously, so that descendants can call it.
I see TComponent also has a SetName() method [the actual setter method for
the Name property], and the SetName() method actually calls the
ChangeName() method.
procedure SetName(const NewName: TComponentName); virtu
24.03.2010 21:24, Graeme Geldenhuys wrote:
The TComponent.SetName is virtual, so that solves my problem, but I still
don't see why ChangeName is even there? Why have two methods to do one
task? What purpose does ChangeName() have? Why couldn't SetName() set the
internal field variable FName?
Paul Ishenin het geskryf:
>>
> SetName obviosly more than just set FName. And how to protect FName and
> at the same time give a way to change it without hooking the events?
OK, that make sense, but then the same could be accomplished by simply
moving FName to the protected section. After all