HOW TO
Instructions provided capture a mouse click in map units. A mouse click can be captured using the MouseDown event of a UI Tool Control. This event returns the mouse click coordinates in device units. Use the IDisplayTransformation::ToMapPoint method to convert from device units to map units.
Note:
For more information on creating a UIControl, see the ArcGIS Desktop Help topic 'How to create custom commands with VBA.'
Code:
' x and y define the point the user clicked in device units
Dim pPoint As IPoint
Dim pApp As IMxApplication
Set pApp = Application
' convert mouse click to map units
Set pPoint = pApp.Display.DisplayTransformation.ToMapPoint(x, y)
MsgBox "User clicked coordinate: " & pPoint.x & ", " & pPoint.y
Article ID:000007163
Get help from ArcGIS experts
Download the Esri Support App