Search code examples
delphi

Create a new component compatible with VCL and FMX


I'm doing some components and I want to do them compatibles for VCL and FMX. So I have a structure that follows this pattern:

General_dpk (with TCustomMyClass) + VCL_dpk (with TMyClass) + FMX_dpk (with TMyClassFMX)

Each package have their register procedure that registered their components. In the components palette appears both components (VCL and FMX). How to do that only appears the components according the type of project selected (VCL or FMX) like the others Delphi components?

Thanks


Solution

  • Well, after a long search I have asked in the Embarcadero forum. There, Remy said me the answer kindly (easy when you know it). The thing is that you need to call GroupDescendentsWith function into the register procedure like this

    // para componentes VCL
    GroupDescendentsWith(TMyClass, Vcl.Controls.TControl);
    
    // para componentes FMX
    GroupDescendentsWith(TMyClassFMX, Fmx.Types.TControl);
    

    The answer on Embarcadero forum here