How to check if PolyList item is selected?

Or selected index in C++ Builder?

So far I've tried something like this:

    for (int i = 0; i < AdvPolyList_Selection->ItemCount(); i++)
        {
        if (AdvPolyList_Selection->Items->InheritsFrom(__classid(TTextItem)))
            {
            TTextItem* ti;
            ti = (TTextItem*)AdvPolyList_Selection->Items;
            if (ti->State == TItemState() << isSelected)
                {
                // do something
                }
            }
        }

Also tried:

            if (ti->State.Contains(isSelected))

These are usually used with C++ Builder and sets but these don't work. So how to check if it is selected?

Assuming TItemState() is enumerated type and State can have only one value out of the following:

TItemState = (isNormal, isDown, isHovered, isSelected);


which translates to c++:

enum TItemState { isNormal, isDown, isHovered, isSelected };

then it can be compared by using:

if (ti->State == Gdipcustomitem::isSelected)

If compared without Gdipcustomitem:: prefix you get ambiguity error.

Once again, this is, assuming that TItemState is not a set and can only have one of the above values at the time.