Reputation: 327
I'm trying to add a context menu when right click a file in explorer.
IFACEMETHODIMP FContextMenuExt::QueryContextMenu(
HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
...
InsertMenuItem(hMenu, 0, TRUE, &mii);
...
}
The menu was added, but did not place the menu on top. It seems on the 5th or 6th place.
Can anyone give me some advice?
Upvotes: 0
Views: 327
Reputation: 69734
You are not supposed to provide a position for your context menu items. Shell builds context menu with items/commands it obtains from several sources: its own GUI items, context menu handlers, registry commands etc. A context menu handler is requested to add its commands to a menu being built, and menu owner continues with adding items, including on top of the menu.
You could possibly set a hook to intercept menu popup and update it before it is shown to user and after it is completely built, but again - this is not what you are really supposed to do.
Upvotes: 1