I am using pInvoke, IShellExtInit and IContextMenu to add a context menu to the explorer shell in C#.
I can add a single item to the context menu using the following code:
MENUITEMINFO mii = new MENUITEMINFO();
mii.cbSize = (uint)Marshal.SizeOf(mii);
mii.fMask = MIIM.MIIM_BITMAP | MIIM.MIIM_STRING | MIIM.MIIM_FTYPE | MIIM.MIIM_ID | MIIM.MIIM_STATE ;
mii.wID = idCmdFirst + increment;
mii.fType = MFT.MFT_STRING;
mii.dwTypeData = contextMenuItem.ItemText;
mii.fState = MFS.MFS_ENABLED;
mii.hbmpItem = this._pMenuBitmap;
NativeMethods.InsertMenuItem(hMenu, increment, true, ref mii)
What I’d like to do is add a menu tree; i.e. add a submenu to the newly created menu item. My first instinct was to use:
var subMenu = mii.hSubMenu;
...
NativeMethods.InsertMenuItem(subMenu,....)
But submenu is always a zero value.
Can anyone help me?
I presume you mean you want to have a cascading submenu that pops out ?
You need to use:
CreatePopupMenu()to create a new menuMENUITEMINFOwhere you set the.hSubMenuto the handle of your menu, and use theMIIM_SUBMENU | MIIM_TYPEmask, to insert into the context menu you get viaIContextMenu:QueryContextMenu.http://forum.cockos.com/archive/index.php/t-20799.html