We can assume that your class is non-visual and that, further, it is not a design-time component. If this were not the case then it would not be otherwise already compatible with both FMX and VCL.
With that being the case, there is no reason you can't include FMX.Types
in a VCL application and there is further no reason that you can't create an FMX.Types.TTimer
in a VCL application - you simply can't do it at design time (ie: drop an FMX TTimer
on a VCL form). If you only need the timer internally, then the answer is clear - just use an FMX timer since it will compile no matter the platform target or the framework being used.
unit FMXTimerInVCLApplication;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
FMX.Types;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
FTimer : TTimer; // FMX.Types.TTimer !
procedure foo(Sender : TObject);
end;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
FTimer := TTimer.Create(nil);
FTimer.Interval := 1000;
FTimer.OnTimer := foo;
end;
procedure TForm1.foo(Sender : TObject);
begin
ShowMessage('foo');
end;
end.
This does bring a fair bit of FMX baggage into your application, of course. It's a lot of bloat for a timer, if you care about that sort of thing. I present it as an alternative to the other natural answer (which is writing your own).