Hi Will!
I figured out (with your help: )) how to run this on a UIToolControl. In fact I finally found several possibilities.
BUT: How can I use it in a FORM?
I tried to copy the CODE to a CommandButton in my Form but there it doesn't work. It runs but I can not fire the selecting mouseclick so I always get "0 Areas selected". I tried many different ways all of them working fine on the UIToolControl but none is running in my Form.
For the UITollControl I get this wrapper line:
Private Sub UIToolQuery_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
For Mousedown in the form I get this wrapper line:
Private Sub From1_MouseDown(ByVal button As Integer, ByVal shift As Integer, ByVal x As Single, ByVal y As Single)
I guess somewhere in there must be the problem but no idea how to solve it.
Anyboy an idea?
P.s. The Code that is running fine on my UITollControl:
Private Sub UIToolQuery_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
' Part 1: Get the point clicked by the user.
Dim pMxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim m_blnMouseDown As Boolean
Dim pPoint As IPoint
Set pMxDoc = ThisDocument
Set pActiveView = pMxDoc.FocusMap
' Convert teh entered point from display coordinates to map coordinates.
Set pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
' Part 2: Perform a spatial query of features within 20,000 meters of the entered point.
Dim pLayer As IFeatureLayer
Dim pSpatialFilter As ISpatialFilter
Dim pTopoOperator As ITopologicalOperator
Dim pSelection As IFeatureSelection
Dim pElement As IElement
Dim pSelectionSet As ISelectionSet
Set pLayer = pMxDoc.FocusMap.Layer(1)
' Create a 20000-meter buffer polygon around the clicked point.
Set pTopoOperator = pPoint
Set pElement = New PolygonElement
pElement.Geometry = pTopoOperator.Buffer(20000)
' Create a spatial filter for selecting features within the buffer polygon.
Set pSpatialFilter = New SpatialFilter
pSpatialFilter.SpatialRel = esriSpatialRelContains
Set pSpatialFilter.Geometry = pElement.Geometry
' Refresh the active view.
pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
' Perform spatial query.
Set pSelection = pLayer
pSelection.SelectFeatures pSpatialFilter, esriSelectionResultNew, False
' Refresh the active view to highlight the selected features.
pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
' Create a selection set and report number of features in the set.
Set pSelectionSet = pSelection.SelectionSet
MsgBox pSelectionSet.count & " Areas selected."
End Sub