Search code examples
c++firemonkeyc++builder-10-seattlec++builder-10.1-berlin

A descendant of TStyledPresentationProxy has not been registered for class


I have a custom grid control that inherits from TGrid called TFmGrid. This control was working fine in Rad Studio 10 Seattle Update One. I recently upgraded to 10.1 Berlin and started noticing this error message showing up on my TFmGrid controls both when I run the application and in the designer:

A descendant of TStyledPresentationProxy has not been registered for class TFmGrid. Maybe it is necessary to add the FMX.Grid.Style module to the uses section

The image below shows how the error message shows up on my grid controls:

enter image description here

I started by doing as the message suggests, and adding #include <FMX.Grid.Style.hpp> to the header file of my TFmGrid control, however this seems to have done nothing.

So as far as trying to register a decendant of TStyledPresentationProxy I am not exactly sure where to start. I found this documentation about a method which:

Attempts to register the presentation proxy class with the specified name or the specified combination of control class and control type.

So I assume I need to use this method or at least something similar, but I don't understand how I am supposed to go about calling this method.

But then that brings up the question of WHERE do I call this code?

My custom control has a method in its namespace called Register() which I believe was autogenerated by the IDE when the control was created:

namespace Fmgridu
{
    void __fastcall PACKAGE Register()
    {
        TComponentClass classes[1] = {__classid(TFmGrid)};
        RegisterComponents(L"Kalos FM Controls", classes, 0);
    }
}  

Do I need to call something in there to register a decendant of TStyledPresentationProxy? What is the proper way to go about this?


Solution

  • Just override virtual method DefinePresentationName in you TfmGrid and return name of presentation name for grid:

    function TfmGrid.DefinePresentationName: string;
    begin
      Result := 'Grid-' + GetPresentationSuffix;
    end;
    

    Fm registers presentation by string name and uses class name for it, so if you create new component (based on existed) you automatically change classname, so system cannot find presentation for you. There are two solution:

    1. Said that you will use presentation from TGrid (DefinePresentationName)
    2. Register existed presentation for you class (look at the initialization section of FMX.Grid.Style.pas)

    P.S. Year ago i wrote article about it in common eNew approach of development of FireMonkey control “Control – Model – Presentation”. Part 1 I hope it will help you