I think you're misunderstanding Delphi's is operator.
It doesn't do what you think it does.
It does do what you want it to do.
Try the following:
LVar := TList.Create;
if LVar is TList then ShowMessage('Var is a TList');
if LVar is TObject then ShowMessage('Var is also a TObject');
However ClassParent
returns a TClass
and so you can't use is. However, you can use InheritsFrom
. I.e.
if ClassParent.InheritsFrom(TVMDNode) then
Disclaimer: However, you might what to rethink your design. As a general rule you want to avoid all that typecasting. In OO each object has a particular type so that you know what you can do to it. Subclassing means you can do all the same things you could do to the ancestor. However overridden virtual methods may do things differently.