Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator IS with a TFormClass

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?

like image 977
Eduardo Stefanello Avatar asked Nov 11 '19 19:11

Eduardo Stefanello


1 Answers

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);
like image 81
David Heffernan Avatar answered Sep 20 '22 12:09

David Heffernan