Hi Timo,
I have a selection of items in a ITreeViewItems class. I would like to iterate over this selection using a for loop until Count(). I see you have an Items() function that should do the job, but I do not know what to pass as parameter for the itemIdentifierType. I tried iitID, that does not seem to work and iitHandle expects a valid item handle....
Kind regards,
Chris
Iterating a ITreeViewItems collection
In VB you use a For-Each loop:
C++ doesn't have such a construct, but you can do what For Each is doing behind the scences:
HTH
TiKu
Code: Select all
Dim ti As TreeViewItem
For Each ti In ExTvw.TreeItems
' do something with ti
Next ti
Code: Select all
// pTvwItems is a ITreeViewItems*
IEnumVARIANT* pEnumerator;
pTvwItems->QueryInterface(IID_IEnumVARIANT, reinterpret_cast<void**>(&pEnumerator));
if(pEnumerator) {
VARIANT item;
VariantInit(&item);
ULONG dummy = 0;
while(pEnumerator->Next(1, &item, &dummy) == S_OK) {
if((item.vt == VT_DISPATCH) && item.pdispVal) {
ITreeViewItem* pTvwItem;
item.pdispVal->QueryInterface(IID_ITreeViewItem, reinterpret_cast<void**>(&pTvwItem));
if(pTvwItem) {
// do something with pTvwItem
pTvwItem->Release();
}
}
VariantClear(&item);
}
pEnumerator->Release();
}
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!