Select to view content in your preferred language

Create Point on screen - Trigger mousedown via form

678
3
02-20-2012 01:37 AM
PriyankaMehta
Deactivated User
Hi all,

  I have a add in  where a button calls a form which has various buttons and work through onClick event.

I want to create one more button on this form that can create a point by clicking mouse button on screen and also retrieve its XY coordinate

Thanks in advance,
Priyanka
0 Kudos
3 Replies
NeilClemmons
Honored Contributor
Create a tool that allows the user to click the map.  In the button click event on your form, get a reference to this tool from IDocument::CommandBars and set it to be the current tool.  When implementing your tool, create a custom event called OnPointClicked or something like that.  Create a custom event arguments class that contains an IPoint reference as one of its properties.  Your custom event should use this custom arguments class for its arguments.  In the custom tool's MouseDown event, create a new instance of the custom arguments class, set the point property to be the point clicked and raise the event.  In the button click event on your form, register for this event before setting the custom tool to be the current tool.  Wire the event to a method on your form that will do whatever you need to do with the point.
0 Kudos
PriyankaMehta
Deactivated User
Hi Neil,
  Thanks for the reply.
I still have some doubts.

Create a tool that allows the user to click the map.


Earlier I was using 9.3 there I used to create a UI Tool control for such purposes. Now that I am using version 10,
I am not really being able to find / create a tool that would allow the user to click the map !! So basically, the main problem I am facing is
"clicking on screen/map" since I cant find UI Tool control or something similar to that in version 10.


Regards,
Priyanka
0 Kudos
NeilClemmons
Honored Contributor
Add-ins can be commands or tools so you just need to create an add-in of the correct type (tool) to use from the button on your form.  I'm not sure how you get references to add-ins through code (I don't work regularly with ArcGIS 10) so using an add-in for the tool may not be the best or easiest choice.  You can always create commands and tools by implementing the ICommand and ITool interfaces.  If you do this then you will need to register these classes during deployment whereas you wouldn't if you create add-ins.  That may or may not be a concern for you but just wanted to mention it.
0 Kudos