ahshegis
路人甲
路人甲
  • 注册日期2004-10-22
  • 发帖数181
  • QQ
  • 铜币847枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1230回复:1

矩形拉框选择要素??

楼主#
更多 发布于:2005-09-05 17:07
VB+AO中,用矩形拉框选择要素应该怎么做?<img src="images/post/smile/dvbbs/em12.gif" />
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-09-05 17:33
<P>在帮助里就有的,这是我写的一个函数,仅供参考</P>
<P>'功能:拉框选择地物<BR>Private Sub SelectByShape(pGeo As IGeometry)<BR>    '定义临时变量<BR>    Dim ff_m_FeatureLayer As IFeatureLayer<BR>    Dim ff_m_FeatureClass As IFeatureClass<BR>    Dim ff_m_SpatialFilter As ISpatialFilter<BR>    Dim ff_m_Filter As IQueryFilter<BR>    Dim ff_m_ActiveView As IActiveView<BR>    <BR>    <BR>    On Error GoTo Select_err<BR>    If ff_m_CurLayer Is Nothing Then Exit Sub<BR>    Set ff_m_FeatureLayer = ff_m_CurLayer<BR>    Set ff_m_FeatureClass = ff_m_FeatureLayer.FeatureClass<BR>    If ff_m_FeatureClass Is Nothing Then Exit Sub<BR>    <BR>    '屏幕坐标转换为地图坐标<BR>    Set ff_m_ActiveView = ff_m_Map<BR>           <BR>   <BR>    '清除前一个选择<BR>    'ff_m_Map.ClearSelection<BR>    'ff_m_ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing<BR>    <BR>    '设置空间过滤<BR>    Set ff_m_SpatialFilter = New SpatialFilter<BR>    Set ff_m_SpatialFilter.Geometry = pGeo<BR>    Select Case ff_m_FeatureClass.ShapeType<BR>    Case esriGeometryPoint<BR>        ff_m_SpatialFilter.SpatialRel = esriSpatialRelContains<BR>    Case esriGeometryPolyline<BR>        ff_m_SpatialFilter.SpatialRel = esriSpatialRelIntersects<BR>    Case esriGeometryPolygon<BR>        ff_m_SpatialFilter.SpatialRel = esriSpatialRelIntersects<BR>    End Select<BR>    ff_m_SpatialFilter.GeometryField = ff_m_FeatureClass.ShapeFieldName<BR>    Set ff_m_Filter = ff_m_SpatialFilter<BR>    <BR>    ' 空间查询<BR>    Dim ff_m_Cursor As IFeatureCursor<BR>    Set ff_m_Cursor = ff_m_FeatureLayer.Search(ff_m_Filter, False)<BR>    <BR>    ' 在地图上选择特征<BR>    Dim ff_m_Feature As iFeature<BR>    Set ff_m_Feature = ff_m_Cursor.NextFeature<BR>    <BR>    '高亮显示<BR>    While Not ff_m_Feature Is Nothing<BR>      ff_m_Map.SelectFeature ff_m_CurLayer, ff_m_Feature<BR>      Set ff_m_Feature = ff_m_Cursor.NextFeature<BR>    Wend<BR>    <BR>    '地图刷新esriViewGeoSelection<BR>    ff_m_ActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing<BR>    <BR>    Exit Sub<BR>Select_err:<BR>    MsgBox Err.Description, vbOKOnly, "错误"<BR>End Sub<BR></P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部