Eduardo Stefanello
Eduardo Stefanello

Reputation: 107

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?

Upvotes: 6

Views: 170

Answers (1)

David Heffernan
David Heffernan

Reputation: 612954

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);

Upvotes: 10

Related Questions