阅读:1853回复:1
[求助]帮忙看下选择元素的代码?谢谢
帮忙看下选择元素的代码?谢谢<BR><BR>
<DIV>void CTestAeView::SelectElement(long x,long y) <BR>{<BR> pActiveView = m_ipmap;<BR>IEnumElementPtr pEnumElem;<BR>IGraphicsContainerPtr pGraphicsContainer(m_ipmap);<BR>IGraphicsContainerSelectPtr pGraphicsContainerSelect(m_ipmap);<BR>IRubberBandPtr pRubberBand(CLSID_RubberEnvelope);<BR>IScreenDisplayPtr pScreenDisplay;<BR>IEnvelope2Ptr pEnvelop(CLSID_Envelope);<BR>IGeometry2Ptr pGeom(pEnvelop);<BR> pActiveView->get_ScreenDisplay(;pScreenDisplay);<BR>pRubberBand->TrackNew(pScreenDisplay,NULL,NULL);<BR>pGraphicsContainerSelect->UnselectAllElements();<BR>if (pEnvelop == NULL)<BR>{<BR> IDisplayTransformationPtr pDisplayTransformation;<BR> pScreenDisplay->get_DisplayTransformation(;pDisplayTransformation);<BR> IPointPtr pPoint(CLSID_Point);<BR> pDisplayTransformation->ToMapPoint(x,y,;pPoint);<BR> double w;<BR> pEnvelop->get_Width(;w);<BR> pActiveView->put_Extent(pEnvelop);<BR> pGraphicsContainer->LocateElements(pPoint,w/200,;pEnumElem);<BR>}<BR>else<BR>{<BR> pGraphicsContainer->LocateElementsByEnvelope(pEnvelop,;pEnumElem);<BR>}<BR>if (pEnumElem != NULL)<BR>{<BR> pGraphicsContainerSelect->UnselectAllElements();<BR> pEnumElem->Reset();<BR> pGraphicsContainerSelect->SelectElements(;pEnumElem);<BR> IElementPtr pElement;<BR> pEnumElem->Next(;pElement);<BR>}<BR> pActiveView->PartialRefresh(esriViewGraphicSelection,NULL,NULL);<BR>}<BR>为什么选不中元素?问题出在哪里?</DIV> |
|
1楼#
发布于:2007-12-26 10:12
你用pActiveView.Refresh()刷新一下试试。
|
|