思仁
路人甲
路人甲
  • 注册日期2005-12-25
  • 发帖数31
  • QQ
  • 铜币122枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1709回复:1

请教:VC+A0用UniqueValueRenderer给美国各州填充颜色代码出错?

楼主#
更多 发布于:2007-04-29 19:46
<DIV >void CGrapeSysView::OnUniquerender() <BR>{<BR><BR>IActiveViewPtr pActiveView(m_ipMap);<BR>const CString strNameFiled="STATE_NAME";<BR>ILayerPtr ilyr;<BR>IGeoFeatureLayerPtr pGeoLayer;<BR>pGeoLayer=ilyr;<BR>IUniqueValueRendererPtr pUniqueValueRenderer(CLSID_UniqueValueRenderer);<BR>IColorPtr pColor;<BR>IColorPtr pNextUniqueColor;<BR>IEnumColorsPtr pEnumRamp;<BR>ITablePtr pTable;<BR>long fieldNumber;<BR>IRowPtr pNextRow;<BR>IRowBufferPtr pNextRowBuffer;<BR>ICursorPtr pCursor;<BR>IQueryFilterPtr pQueryFilter(CLSID_QueryFilter);<BR>VARIANT codeValue;<BR>VariantInit(;codeValue);<BR>codeValue.vt=VT_BSTR;<BR>pTable=pGeoLayer;<BR>pTable->FindField(_bstr_t(strNameFiled),;fieldNumber);<BR>ASSERT(fieldNumber!=-1);<BR>pUniqueValueRenderer->put_FieldCount(1);<BR>pUniqueValueRenderer->put_Field(0,_bstr_t(strNameFiled));<BR>IRandomColorRampPtr pColorRamp(CLSID_RandomColorRamp);<BR>pColorRamp->put_StartHue(0);<BR>pColorRamp->put_EndHue(360);<BR>pColorRamp->put_MinValue(99);<BR>pColorRamp->put_MinSaturation(15);<BR>pColorRamp->put_MaxValue(100);<BR>pColorRamp->put_MaxSaturation(30);<BR>pColorRamp->put_Size(100);<BR>VARIANT_BOOL bok;<BR>pColorRamp->CreateRamp(;bok);<BR>pColorRamp->get_Colors(;pEnumRamp);<BR>pNextUniqueColor=NULL;<BR>pQueryFilter->AddField(_bstr_t(strNameFiled));<BR>pTable->Search(pQueryFilter,TRUE,;pCursor);<BR>pCursor->NextRow(;pNextRow);<BR>while (pNextRow) {<BR>  pNextRowBuffer=pNextRow;<BR>  pNextRowBuffer->get_Value(fieldNumber,;codeValue);<BR>  pEnumRamp->Next(;pNextUniqueColor);<BR>  if (pNextUniqueColor=NULL) {<BR>   pEnumRamp->Reset();<BR>   pEnumRamp->Next(;pNextUniqueColor);<BR>  }<BR>  ISimpleFillSymbolPtr pFillSym(CLSID_SimpleFillSymbol);<BR>  ISymbolPtr pSym;<BR>  pFillSym->put_Color(pNextUniqueColor);<BR>  pSym=pFillSym;<BR>  pUniqueValueRenderer->AddValue(codeValue.bstrVal,codeValue.bstrVal,pSym);<BR>  pCursor->NextRow(;pNextRow);<BR>}<BR>IFeatureRendererPtr pFeatrenderer;<BR>pFeatrenderer=pUniqueValueRenderer;<BR>pGeoLayer->putref_Renderer(pFeatrenderer);<BR><BR>pActiveView->Refresh();   // 调试运行后, 到这里出错,不知道是怎么会事情<BR><BR>}<BR><BR>我用的是9.0的</DIV>
喜欢0 评分0
promzaid
路人甲
路人甲
  • 注册日期2006-12-31
  • 发帖数4
  • QQ
  • 铜币130枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-08-31 20:04
 IMapPtr pMap;<BR> m_ipMap->get_Map(;pMap);<BR>
<P> IActiveViewPtr pActiveView;<BR> pActiveView = pMap;</P>
<P>.......</P>
<P> pActiveView->Refresh();<BR></P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部