Imports ESRI.ArcGIS.ArcMapUI Imports ESRI.ArcGIS.Carto Public Class Identify_Button Inherits ESRI.ArcGIS.Desktop.AddIns.Button Dim pMxDoc As IMxDocument Dim activeView As IMap Public Sub DoIdentify(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal x As System.Int32, ByVal y As System.Int32) pMxDoc = My.ArcMap.Application.Document activeView = pMxDoc.FocusMap If activeView Is Nothing Then Return End If Dim map As ESRI.ArcGIS.Carto.IMap = activeView.FocusMap Dim identifyDialog As ESRI.ArcGIS.CartoUI.IIdentifyDialog = New ESRI.ArcGIS.CartoUI.IdentifyDialogClass identifyDialog.Map = map 'Clear the dialog on each mouse click identifyDialog.ClearLayers() Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay = activeView.ScreenDisplay Dim display As ESRI.ArcGIS.Display.IDisplay = screenDisplay ' Implicit Cast identifyDialog.Display = display Dim identifyDialogProps As ESRI.ArcGIS.CartoUI.IIdentifyDialogProps = CType(identifyDialog, ESRI.ArcGIS.CartoUI.IIdentifyDialogProps) ' Explicit Cast Dim enumLayer As ESRI.ArcGIS.Carto.IEnumLayer = identifyDialogProps.Layers enumLayer.Reset() Dim layer As ESRI.ArcGIS.Carto.ILayer = enumLayer.Next Do While Not (layer Is Nothing) identifyDialog.AddLayerIdentifyPoint(layer, x, y) layer = enumLayer.Next() Loop identifyDialog.Show() End Sub Public Sub New() End Sub Protected Overrides Sub OnClick() DoIdentify(activeView, 300, 100) End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcMap.Application IsNot Nothing End Sub End Class
Sub test()
Dim pMxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim pIdentifyDialog As IIdentifyDialog
Dim pIdentifyDialogProps As IIdentifyDialogProps
Dim pEnumLayer As IEnumLayer
Dim pLayer As ILayer2
Set pMxDoc = Application.Document
Set pActiveView = pMxDoc.FocusMap
Set pIdentifyDialog = New IdentifyDialog
Set pIdentifyDialogProps = pIdentifyDialog
Set pIdentifyDialog.Map = pMxDoc.FocusMap
Set pIdentifyDialog.Display = pActiveView.ScreenDisplay
pIdentifyDialog.ClearLayers
Set pEnumLayer = pIdentifyDialogProps.Layers
pEnumLayer.Reset
Set pLayer = pEnumLayer.Next
Do While Not pLayer Is Nothing
pIdentifyDialog.AddLayerIdentifyOID pLayer, 4
Set pLayer = pEnumLayer.Next
Loop
pIdentifyDialog.Show
End Sub
Imports ESRI.ArcGIS.ArcMapUI Imports ESRI.ArcGIS.Carto Imports ESRI.ArcGIS.Display Imports ESRI.ArcGIS.CartoUI Imports ESRI.ArcGIS.Geodatabase Public Class ShowSelectedWR Inherits ESRI.ArcGIS.Desktop.AddIns.Button Dim pMxDoc As IMxDocument Dim activeView As IMap Sub test() Dim pMxDoc As IMxDocument Dim pActiveView As IActiveView Dim pIdentifyDialog As IIdentifyDialog Dim pIdentifyDialogProps As IIdentifyDialogProps Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer2 Dim pFtrLyr As IFeatureLayer Dim pFtrSel As IFeatureSelection Dim pFtrCsr As IFeatureCursor Dim pFtr As IFeature pMxDoc = My.ArcMap.Application.Document pActiveView = pMxDoc.FocusMap pIdentifyDialog = New IdentifyDialog pIdentifyDialogProps = pIdentifyDialog pIdentifyDialog.Map = pMxDoc.FocusMap pIdentifyDialog.Display = pActiveView.ScreenDisplay pIdentifyDialog.ClearLayers() pEnumLayer = pIdentifyDialogProps.Layers pEnumLayer.Reset() pLayer = pEnumLayer.Next ' Get a ref to the first layer pFtrLyr = pMxDoc.FocusMap.Layer(0) ' Get a cursor on the selected features in this layer pFtrSel = pFtrLyr ' Sets cursor to start at beginning of selected feature pFtrSel.SelectionSet.Search(Nothing, False, pFtrCsr) ' loop thru selected features and display OID of each pFtr = pFtrCsr.NextFeature While Not pLayer Is Nothing Do While Not pFtr Is Nothing 'MsgBox("Before pFtr NextFeature Call") pIdentifyDialog.AddLayerIdentifyOID(pLayer, pFtr.OID) Debug.Print(pFtr.OID) pFtr = pFtrCsr.NextFeature 'MsgBox("End of First Loop") Loop ' Loop to move through layers and NOT call identify loop unless ' there are selected records. pLayer = pEnumLayer.Next If Not pLayer Is Nothing Then pFtrLyr = pLayer pFtrSel = pFtrLyr pFtrSel.SelectionSet.Search(Nothing, False, pFtrCsr) Debug.Print(pFtrLyr.Name) pFtr = pFtrCsr.NextFeature End If End While pIdentifyDialog.Show() End Sub Public Sub New() End Sub Protected Overrides Sub OnClick() test() End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcMap.Application IsNot Nothing End Sub End Class