Connect a tool embedded in a Windows Form

Discussion created by gorkemt on Aug 16, 2012
Latest reply on Aug 16, 2012 by gorkemt
I'm trying to get x and y coordinates from the map when I click it. The mousedown event is initialized by the button(tool) which is embedded in a windows form. The windows form resides in the ArcMap application. The problem is initializing (activating) the mouse down event by the windows button. Any suggestions would be great. 

Here is the windows button click event:

Private Sub btnMapSelection_Click(sender As System.Object, e As System.EventArgs) Handles btnMapSelection.Click

        Dim pTool As New CoordinateSelectorTool


        Dim UIDCls As ESRI.ArcGIS.esriSystem.IUID = New ESRI.ArcGIS.esriSystem.UIDClass
        UIDCls.Value = "CTM.GIS.GISDesktop.CoordinateSelectorTool"
        Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem = _application.Document.CommandBars.Find(UIDCls)

        If commandItem Is Nothing Then
            Exit Sub
        End If

        _application.CurrentTool = commandItem
        '_application.CurrentTool = GetCommandItem("{94ea5994-2e62-44b7-8786-a0d0075e91e8}")
    End Sub

ArcObject Tool:

Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer)

        Dim pMxDoc As IMxDocument
        pMxDoc = m_application.Document
        ClickPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y)
        'TODO: Add CoordinateSelectorTool.OnMouseDown implementation
    End Sub