Operator IS with a TFormClass
Asked Answered
W

1

6

I've a follow situation:

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;

The both lines does not build, the error is Operator not applicable to this operand type.

How can I do this comparation?

Wilmot answered 11/11, 2019 at 19:19 Comment(0)
B
10

The lhs of the is operator should be an instance, but you have provided a class.

What you need is the InheritsFrom class method:

AClass.InheritsFrom(TMyForm);
Byerly answered 11/11, 2019 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.