Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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);
  }
}
share|improve this question
    
Which version of ArcGIS Desktop are you developing for? –  blah238 Nov 26 '12 at 5:29
    
arcGis Desktop 9.3.1 –  user13085 Nov 26 '12 at 5:50
add comment

1 Answer 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
}
share|improve this answer
    
Thank you Aragon for reformatting the code. –  Michael Miles-Stimson Feb 12 '13 at 23:20
    
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). –  Michael Miles-Stimson Feb 12 '13 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 –  Michael Miles-Stimson Feb 12 '13 at 23:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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