2

I have a created a custom context menu using ICommandBar and am displaying it on create feature mouse-down right click. I am constructing a point collection on each mouse down and then creating a polyline. For each point I am refreshing using EditSketch.RefreshSketch().

On right click, I created a custom context menu to finish the sketch. Sometimes, I get the default "Sketch Tool/Select Elements" context menu, which I do not want to get on right click.

The code that I'm using to display the context menu:

public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
  if (Button == 2)
  {
    _objContextMenu.Popup(0, 0);
  }
}
2
  • Which version of ArcGIS Desktop are you developing for?
    – blah238
    Commented Nov 26, 2012 at 5:29
  • arcGis Desktop 9.3.1
    – user13085
    Commented Nov 26, 2012 at 5:50

1 Answer 1

1

You need to 'short circuit' the OnContextMenu and tell ArcGIS that everything's sorted.

public override bool OnContextMenu(int X, int Y)

{
      return true; // or allow some condition where the context menu is allowed
}
2
  • My apologies for the one line answer, I was in a hurry when I wrote it. In order to dismiss the existing context menu one must override the OnContextMenu then you can use the OnMouseDown (if Button == 2) for a right click. The coordinates given for the OnMouseDown are in screen coordinates from the application (ArcMap) window, once you know ArcMap's location add it to the X and Y to set the form properties me.Left and me.Top (I think that's VB but C# has something similar). Commented Feb 12, 2013 at 23:29
  • The IWindowPosition object will give you the location of the ArcMap frame, this post discusses the windows location of the screen display link Commented Feb 12, 2013 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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