带有 TFormClass 的 Operator IS
Operator IS with a TFormClass
我有以下情况:
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;
这两行都没有建立,错误是Operator not applicable to this operand type.
如何进行比较?
is
运算符的lhs应该是一个实例,但是你提供了一个class.
你需要的是InheritsFrom
class方法:
AClass.InheritsFrom(TMyForm);
我有以下情况:
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;
这两行都没有建立,错误是Operator not applicable to this operand type.
如何进行比较?
is
运算符的lhs应该是一个实例,但是你提供了一个class.
你需要的是InheritsFrom
class方法:
AClass.InheritsFrom(TMyForm);