阅读:1714回复:1
请教:VC+A0用UniqueValueRenderer给美国各州填充颜色代码出错?void CGrapeSysView::OnUniquerender() { IActiveViewPtr pActiveView(m_ipMap); const CString strNameFiled="STATE_NAME"; ILayerPtr ilyr; IGeoFeatureLayerPtr pGeoLayer; pGeoLayer=ilyr; IUniqueValueRendererPtr pUniqueValueRenderer(CLSID_UniqueValueRenderer); IColorPtr pColor; IColorPtr pNextUniqueColor; IEnumColorsPtr pEnumRamp; ITablePtr pTable; long fieldNumber; IRowPtr pNextRow; IRowBufferPtr pNextRowBuffer; ICursorPtr pCursor; IQueryFilterPtr pQueryFilter(CLSID_QueryFilter); VARIANT codeValue; VariantInit(;codeValue); codeValue.vt=VT_BSTR; pTable=pGeoLayer; pTable->FindField(_bstr_t(strNameFiled),;fieldNumber); ASSERT(fieldNumber!=-1); pUniqueValueRenderer->put_FieldCount(1); pUniqueValueRenderer->put_Field(0,_bstr_t(strNameFiled)); IRandomColorRampPtr pColorRamp(CLSID_RandomColorRamp); pColorRamp->put_StartHue(0); pColorRamp->put_EndHue(360); pColorRamp->put_MinValue(99); pColorRamp->put_MinSaturation(15); pColorRamp->put_MaxValue(100); pColorRamp->put_MaxSaturation(30); pColorRamp->put_Size(100); VARIANT_BOOL bok; pColorRamp->CreateRamp(;bok); pColorRamp->get_Colors(;pEnumRamp); pNextUniqueColor=NULL; pQueryFilter->AddField(_bstr_t(strNameFiled)); pTable->Search(pQueryFilter,TRUE,;pCursor); pCursor->NextRow(;pNextRow); while (pNextRow) { pNextRowBuffer=pNextRow; pNextRowBuffer->get_Value(fieldNumber,;codeValue); pEnumRamp->Next(;pNextUniqueColor); if (pNextUniqueColor=NULL) { pEnumRamp->Reset(); pEnumRamp->Next(;pNextUniqueColor); } ISimpleFillSymbolPtr pFillSym(CLSID_SimpleFillSymbol); ISymbolPtr pSym; pFillSym->put_Color(pNextUniqueColor); pSym=pFillSym; pUniqueValueRenderer->AddValue(codeValue.bstrVal,codeValue.bstrVal,pSym); pCursor->NextRow(;pNextRow); } IFeatureRendererPtr pFeatrenderer; pFeatrenderer=pUniqueValueRenderer; pGeoLayer->putref_Renderer(pFeatrenderer); pActiveView->Refresh(); // 调试运行后, 到这里出错,不知道是怎么会事情 } 我用的是9.0的 |
|
1楼#
发布于:2007-08-31 20:04
IMapPtr pMap; m_ipMap->get_Map(;pMap); IActiveViewPtr pActiveView; ....... pActiveView->Refresh(); |
|