Is there a reason TTimerProc used with IFMXTimerService is declared so, without sending through the TimerID/Handle to the callback procedure (in FMX.Types)?

Is there a reason TTimerProc used with IFMXTimerService is declared so, without sending through the TimerID/Handle to the callback procedure (in FMX.Types)?

TTimerProc = procedure of object;

IFMXTimerService = interface(IInterface)
['{856E938B-FF7B-4E13-85D4-3414A6A9FF2F}']
function CreateTimer(Interval: Integer; TimerFunc: TTimerProc): TFmxHandle;
...
end;

With the ID/handle it would be possible to use one TimerProc handler for multiple timers created this way. Looking further into the FMX.Platforms.xxx units I can see the ID/handle is available upto the point of the call to TimerProc (ok on Mac/iOS it will be more involved to get the ID, but it seems possible). Is there an easy way to use the same callback procedure for multiple timers created this way and know which timer fired?

Comments

  1. Personally I wonder mainly why FMX is based on a bunch of Interfaces while virtual classes would have been more natural.

    ReplyDelete
  2. The interfaces thing is /really cool/. It allows functionality to be augmented and replaced, far more easily and abstractly / with being tied to an implementation than if using virtual classes. It also allows behaviour to change and be present or not depending on the platform.

    I've done this to change behaviour on Windows, for example (something to do with mouse handling from memory).

    ReplyDelete

Post a Comment