Option Explicit
Private Function UIToolControl1_Deactivate() As Boolean
UIToolControl1_Deactivate = True
End Function
Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, _
ByVal x As Long, ByVal y As Long)
Dim pMxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim pScreenDisplay As IScreenDisplay
Dim pRubberPolygon As IRubberBand
Dim pFillSymbol As ISimpleFillSymbol
Dim pRgbColor As IRgbColor
Dim pPolygon As IPolygon
Dim pGeometry As IGeometry
Dim pFeatselect As IFeatureSelection
Dim pSpatialFilter As ISpatialFilter
On Error GoTo ErrorHandler:
Set pMxDoc = ThisDocument
Set pActiveView = pMxDoc.FocusMap
'Draw Polygon
Set pScreenDisplay = pActiveView.ScreenDisplay
Set pRubberPolygon = New RubberPolygon
Set pFillSymbol = New SimpleFillSymbol
Set pRgbColor = New RgbColor
pRgbColor.NullColor = True
pFillSymbol.Color = pRgbColor
Set pPolygon = pRubberPolygon.TrackNew(pScreenDisplay, pFillSymbol)
With pScreenDisplay
.StartDrawing pScreenDisplay.hDC, esriNoScreenCache
.SetSymbol pFillSymbol
.DrawPolygon pPolygon
.FinishDrawing
End With
'set up pFilter
Set pGeometry = pPolygon
Set pSpatialFilter = New SpatialFilter
With pSpatialFilter
Set .Geometry = pGeometry
.SpatialRel = esriSpatialRelIntersects
End With
'select
Set pFeatselect = pMxDoc.FocusMap.Layer(0)
pFeatselect.SelectFeatures pSpatialFilter, esriSelectionResultNew, False
pFeatselect.SelectionSet.**
pMxDoc.ActiveView.**
Exit Sub
ErrorHandler:
MsgBox Err.Description
End Sub
|