Coordinates of Mouse click?

5169
4
08-24-2011 02:24 PM
LukeStewart
New Contributor III
I am trying to write an ArcGIS Add-in using ArcObjects and .Net (C#) and I can't figure out how to get the user to click on a button that I have added to ArcMap from the add-in and then from that click on the map and get the co-ordinates or location of the click. This is the first ArcObjects programming I have done and I have managed to get quite a bit done but can not figure this out at all.

Thanks for any help,

Luke
0 Kudos
4 Replies
DubravkoAntonic
New Contributor III
IPoint pPoint = IActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(int x, int y);

x, y are mouse coordinates

http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esridisplay/IDisplayTransformation_ToMap...
from
http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/ao_start.htm
0 Kudos
LukeStewart
New Contributor III
Thanks for your reply. What I still don't understand is how I get the code to run when the mouse is clicked on the map. Or where I actually put this code in my add-in project.

Thanks
0 Kudos
LukeStewart
New Contributor III
ok so I worked this out. I needed to add a tool to my add-in rather than a button and then add this code to activate the onclick event:

protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)

So easy!!!

Thanks,

Luke
0 Kudos
DubravkoAntonic
New Contributor III
These are the basics, it is a good way to follow well documented help from SDK, because 6 and more years ago help didn't have that much examples and snippets.

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/ao_home.html

there is one video that deals with add-ins

http://resources.arcgis.com/gallery/video/arcgis-desktop/details?entryID=F6C89D10-1422-2418-7F87-2A1...
0 Kudos