What he did is a redirection.
Ah, yes, you are correct. I missed the point to assigning a normal procedure.
BTW. I would have suggested a slightly adapted code. There would be no need for using the current FOnTimer. That would even break existing code. If you are inheriting the TFPTimer the 'proper' way to would be to override the caller of FOnTimer. In TFPTimer this would be the Timer procedure itself. That way, the original FOnTimer would still usable but you create an extra FOnProcTimer. At least this is how it's done in all classes throughout the VCL code in Delphi. Something like this:
type
TTimerProc = procedure(Sender: TObject);
TProcTimer = class(TFPTimer)
private
FOnProcTimer: TTimerProc;
protected
procedure Timer; override;
public
property OnProcTimer: TTimerProc read FOnProcTimer write FOnProcTimer;
end;
procedure TProcTimer.Timer;
begin
if Active and Assigned(FOnProcTimer) then
FOnProcTimer(Self);
inherited;
end;
But... there is
a big problem. TFPTimer is really weirdly designed because it uses Assigned(FOnTime) inside StartTimer. So TFPTimer.Timer is create virtual but if you are overriding that in an inherited class, you don't get the expected functionality. They didn't have 'proper' object orientation and inheritance in mind when creating that class.
I would have used TTimer but unfortunately TTimer is depended on the LCL app loop... so... for a quick hack, 'misusing' TFPTimer.OnTimer is fine, but when using this class in a much bigger project, you might also want to override StartTimer (luckely that's also virtual defined) and remove the "Assigned(FOnTimer)" from the if statement at the top.