Search code examples
delphidelphi-xe2firemonkey

Delphi XE2: Is there a predefined conditional to identify VCL and FireMonkey?


In Delphi XE2, we have use

{$ifdef Win32}
{$ifdef Win64}

to identify which platform we are in.

Is there any predefined conditional that may identify VCL and FMX?


Solution

  • As others says, there is not a conditional directive to determine if your application is VCL or FireMonkey. I think the most reliable way to determine if your app is FireMonkey or VCL is using a function instead of a conditional directive.

    Something like

    Uses
     Rtti;
    
    function IsVCLApp:Boolean;
    begin
     Result:= CompareText(TRttiContext.Create.GetType(TApplication.ClassInfo).QualifiedName,'Vcl.Forms.TApplication')=0;
    end;
    
    function IsFireMonkeyApp:Boolean;
    begin
     Result:= CompareText(TRttiContext.Create.GetType(TApplication.ClassInfo).QualifiedName,'FMX.Forms.TApplication')=0;
    end;