In an application that I am developing using VB.Net with ArcObjects 9.3, I am trying to display the "Select By Location" dialog box in my code. I know that I can call it directly using the UID through the ICommandItem interface, but I also need access to the parameters set by the dialog box (e.g. the selection layer, the selection method, and so on-- something that I don't think is possible with the UID method) . Is there a way to do this somehow that I'm missing, similar to the way that you can call the "Select By Attribute" dialog box using the IQueryAttributes interface?

  • I think the short answer is no. Application dialogs don't seem to offer a hook into their interfaces. – Hornbydd Oct 2 '14 at 23:43
  • The Select By Attribute tool has a hook into it, via the IQueryAttribute interface. The third comment on this forum has some example code: forums.esri.com/Thread.asp?c=93&f=993&t=291805 – Mwinslett Oct 3 '14 at 1:20

I have never used that interface so a good find indeed! But I'm still not convinced the dialog is exposed...

An alternative is to open up and display the selectbylocation geo-processing tool? The following VBA code opens the Calculate Field tool but it gives the basic syntax for populating parameters and opening up the interface.

Public Sub OpenCalculateTool()
    ' Hook into Toolbox and get the tool
    Dim pUID As New UID
    pUID = "esriGeoprocessingUI.ArcToolboxExtension"
    Dim pArcToolboxExtension As IArcToolboxExtension
    Set pArcToolboxExtension = Application.FindExtensionByCLSID(pUID)
    Dim pArcToolbox As IArcToolbox
    Set pArcToolbox = pArcToolboxExtension.ArcToolbox
    Dim pGPTool As IGPTool
    Set pGPTool = pArcToolbox.GetToolbyNameString("CalculateField")

    ' Create messages, required by Invoke method
    Dim msgs As IGPMessages
    Set msgs = New GPMessages

    ' Get existing parameter structure
    Dim pArray As IArray
    Set pArray = pGPTool.ParameterInfo

    ' Declare Parameter interfaces
    Dim pGPParameter As IGPParameter
    Dim pGPDataType As IGPDataType
    Dim pGPParameterEdit As IGPParameterEdit

    ' Set the parameters of the tool
    Set pGPParameter = pArray.Element(0)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("a") ' Featurelayer name
    Set pGPParameter = pArray.Element(1)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("xx") ' Field
    Set pGPParameter = pArray.Element(3)
    Set pGPParameterEdit = pGPParameter
    Set pGPDataType = pGPParameter.DataType
    Set pGPParameterEdit.Value = pGPDataType.CreateValue("VB")

    ' Open the tool
    Dim pGPToolCommandHelper As IGPToolCommandHelper2
    Set pGPToolCommandHelper = New GPToolCommandHelper
    pGPToolCommandHelper.SetTool pGPTool
    pGPToolCommandHelper.InvokeModal 0, pArray, True, msgs
End Sub
|improve this answer|||||
  • Awesome! This looks like it might do the job! Thanks so much!! – Mwinslett Oct 6 '14 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.