Holy cow, I wrote a book!
A customer reported a problem with their shell context menu extension.
I have implemented the IContextMenu shell extension,
but when the user selects my custom menu item,
my IContextMenu::InvokeCommand is never called.
Can anyone please let me know what the problem could be and how to fix it?
Since there really isn't much information provided in this request,
I was forced to invoke my psychic powers.
given what you know about shell context menu hosting,
you probably know the answer too.
My psychic powers tell me that you gave your menu item the wrong ID,
or you returned the wrong value
If the menu IDs do not lie in the range you described by the return
value from IContextMenu::QueryContextMenu,
the user chooses the menu item, the item ID will not map to your
In our sample composite context menu,
relies on the component context menu handlers putting their menu IDs
in the range idCmdFirst through
idCmdFirst - return_value - 1.
If the two don't line up,
won't realize that the menu item the user selected corresponds to you.
idCmdFirst - return_value - 1
We never did hear back from the customer,
so the world may never know whether my psychic prediction was correct.
When possible, use a static verb registration instead of an
They are much simpler to implement while still providing
a good amount of expressive power.
provide additional information in your registration
to control things like the conditions under which your verb
should be shown.
You can even
register cascading submenus statically.