Listing types of dimensions in a view |
Top Previous Next |
This code fragment shows you how to get hold of the DimensionConstraints:
CComPtr<ObjectCollection> pAllRetCollection ; hRes = pGenDims->GetRetrievableDimensions (pThisView,gkvarEmpty,&pAllRetCollection) ; if (FAILED (hRes)) { TRACE"Could not get ret dims") ; return ;
} else { WalertBoxA ("Got RetrievableDims ok, there are %d.",pAllRetCollection->Count) ; }
const long ikNumRetDims = pAllRetCollection->Count ;
for (long iDim = 1 ; iDim <= ikNumRetDims ; iDim++) { IDispatchPtr pNthDim; hRes = pAllRetCollection->get_Item(_variant_t(iDim), &pNthDim);
CComPtr<DimensionConstraint> pDimConstraint ; hRes = pNthDim->QueryInterface (__uuidof(DimensionConstraint), (void **)&pDimConstraint);
if (FAILED (hRes)) { TRACE (L"Could not query interface of dim %d of %d\n",iDim,ikNumRetDims) ;
} else { ObjectTypeEnum eType = pDimConstraint->GetType() ; TRACE (L" dim %d is a %d %s\n",iDim,eType,GetObjTypeDesc(eType)) ;
CComPtr<Parameter> pThisParam ; hRes = pDimConstraint->get_Parameter (&pThisParam) ; if (FAILED (hRes)) { TRACE (L"Could not get parameter of dim %d of %d\n",iDim,ikNumRetDims) ;
} else { CComBSTR bstrParamName ; pThisParam->get_Name (&bstrParamName) ; TRACE (L"Param of dim %d is %s\n",iDim,bstrParamName) ; } }
pNthDim = nullptr ; // free the IDispatch pointer }
It also shows you how to get an item as an IDispatchPtr and turn it into a DimensionConstraint (for example), and how to get the name of the parameter which controls the dimension.
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)