c++ - TStyledPresentationProxy 的后代尚未为类注册

标签 c++ firemonkey c++builder-10-seattle c++builder-10.1-berlin

我有一个继承自 TGrid 的自定义网格控件叫TFmGrid 。该控件在 Rad Studio 10 西雅图更新一中运行良好。我最近升级到 10.1 Berlin 并开始注意到我的 TFmGrid 上出现此错误消息当我运行应用程序和设计器时进行控制:

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

下图显示了错误消息如何显示在我的网格控件上:

enter image description here

我首先按照消息的建议进行操作,并添加 #include <FMX.Grid.Style.hpp>到我的TFmGrid的头文件控制,但这似乎没有起到任何作用。

就尝试注册 TStyledPresentationProxy 的后代而言我不太确定从哪里开始。我发现this documentation关于一种方法:

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

所以我认为我需要使用这个方法或至少类似的方法,但我不明白我应该如何调用这个方法。

但这又带来了一个问题:我在哪里调用这段代码?

我的自定义控件在其命名空间中有一个名为 Register() 的方法我相信这是在创建控件时由 IDE 自动生成的:

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

我是否需要调用其中的某些内容来注册 TStyledPresentationProxy 的后代?解决这个问题的正确方法是什么?

最佳答案

只需重写 TfmGrid 中的虚拟方法 DefinePresentationName 并返回网格的演示文稿名称:

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

Fm 通过字符串名称注册演示并为其使用类名,因此如果您创建新组件(基于现有组件),您会自动更改类名,因此系统无法为您找到演示。解决办法有两种:

  1. 表示您将使用 TGrid 中的演示文稿 (DefinePresentationName)
  2. 为您的类(class)注册现有的演示文稿(查看 FMX.Grid.Style.pas 的初始化部分)

附注一年前我写了一篇关于它的共同文章eNew approach of development of FireMonkey control “Control – Model – Presentation”. Part 1希望对您有帮助

关于c++ - TStyledPresentationProxy 的后代尚未为类注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37281970/

相关文章:

android - 德尔福XE8 : No refresh for TRectangle on Android during OnCreate event

openssl - 在 C++Builder 中使用 OpenSSL

c++ - 使用Firedac进行MongoDB的时间范围查询

python - 读取管道(C/C++),没有错误,但不是所有数据

java - 通过删除 PRIME ASCII 字符来打印字符串

c++ - 你怎么能确保一个 C++ 函数可以被调用为

delphi - fmx delphi berlin 如何更改 Tgrid 行中的字体颜色

C# - 图形用户界面问题

C++ 生成器 : Refresh FireMonkey Visual Component

boolean - 将 Variant 转换为 bool