This will be a well-known method name to those of my readers who ever dealt with context menu shell-extensions. Since I am at the moment resuming the work on my own multi-purpose shell-extension, I also searched for resources and there appears to be a strange misconception on how this method should be used.
Here the prototype:
HRESULT IContextMenu::QueryContextMenu( HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags );
There are seriously people who claim that you have to count all of your submenu items as well, meaning that (idCmdLast - idCmdFirst)
items can easily be eaten up by a single context menu shell-extension. They seem to miss the fact that a submenu is another (separate!) entity and can contain as many new menu items as any new menu could. As the MSDN documentation puts it, the only restriction is:
When a context menu handler adds a pop-up menu item, it must use
IContextMenu::QueryContextMenu
to add at least one item to that menu for theWM_INITMENUPOPUP
message to be forwarded.
… which says that the newly added submenu (i.e. popup menu) has to have at least one menu item. I know the documentation isn’t explicit about this, but it says nowhere to count submenu items as well. In fact any logically thinking person has to deduce from the documentation that the submenu is being treated totally separate and that the items in this submenu therefore have no business with the menu into which the submenu was inserted.
Just my two €-cents,
// Oliver
PS: Read on (1.5 year old) here.