【问题标题】:Operator IS with a TFormClass带有 TFormClass 的运算符 IS
【发布时间】:2020-03-07 11:55:33
【问题描述】:

我有以下情况:

TMyFormClass = class of TMyForm

function IsMyClass(AClass: TFormClass);
begin
  Result := AClass is TMyForm      // Operator not applicable to this operand type
  Result := AClass is TMyFormClass // Operator not applicable to this operand type
end;

这两行都没有构建,错误是运算符不适用于此操作数类型

我该如何做这个比较?

【问题讨论】:

    标签: delphi delphi-10.3-rio tform


    【解决方案1】:

    is 运算符的 lhs 应该是一个实例,但你提供了一个类。

    你需要的是InheritsFrom类方法:

    AClass.InheritsFrom(TMyForm);
    

    【讨论】:

      猜你喜欢
      • 2010-12-19
      • 2019-08-18
      • 2022-10-13
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      相关资源
      最近更新 更多