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 looking for solution (using ArcObject SDK 10.1 (VB.NET) ArcMap Addin template) to substitute the default shortcut "right-click" menu in the TOC (When a TOC Item is right-clicked) with a custom menu when a custom tool is active. (I would like default functionality when a custom tool is inactive)

I already do that in the map - I have a custom tool and when the tool I show a custom menu on right-click. The custom behavior only works within the map frame.

How can I do the same in the TOC?

enter image description here

share|improve this question
    
The question in your post "how can i gather information about the TOC item that was right-clicked or left-clicked in the TOC" doesn't really match the question in the title. Anyway, did you try IMxDocument.SelectedItem? –  Kirk Kuykendall Mar 1 '13 at 15:55
    
Thanks @KirkKuykendall. Edited the post. I want to focus on substituting the shortcut menu when a layer in the TOC is right-clicked. –  Jakub Mar 1 '13 at 16:43
add comment

1 Answer

As far as I can tell there is no event exposed in ArcObjects for when a context menu is opened in the TOC, and no entry point to override it.

You would likely have to delve into the Windows API, listen for specific messages and respond to whichever one corresponds to the default context menu display and replace it with your own. This can get really ugly so hopefully there is a better way.

There is some good info in these questions:

It may be possible to use ICustomizationFilter to listen for and block the context menu event but I have not tried it. This blog post shows how something similar can be done within a VB.NET add-in. I am not sure how you would replace the context menu with your own though.

share|improve this answer
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.