Skip to content

Instantly share code, notes, and snippets.

@tablacus
Created August 13, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tablacus/21f28d78acd7f3a944d52094d149fcd8 to your computer and use it in GitHub Desktop.
Save tablacus/21f28d78acd7f3a944d52094d149fcd8 to your computer and use it in GitHub Desktop.
var FV = GetFolderView(Ctrl, pt);
if (FV) {
var hMenu = api.CreatePopupMenu(), hSubMenu;
var ContextMenu = FV.ViewMenu();
if (ContextMenu) {
ContextMenu.QueryContextMenu(hMenu, 0, 1, 0x7fff, CMF_DEFAULTONLY);
var mii = api.Memory("MENUITEMINFO");
mii.cbSize = mii.Size;
mii.fMask = MIIM_SUBMENU;
for (var i = 0; i < api.GetMenuItemCount(hMenu); i++) {
api.GetMenuItemInfo(hMenu, i, true, mii);
if (mii.hSubMenu) {
hSubMenu = mii.hSubMenu;
mii.fMask = MIIM_FTYPE | MIIM_STATE;
for (var j = 0; j < api.GetMenuItemCount(hSubMenu); j++) {
api.GetMenuItemInfo(hSubMenu, j, true, mii);
if (mii.fState & MFS_CHECKED && mii.fType & MFT_RADIOCHECK) {
mii.fMask = MIIM_ID;
if (j) {
api.GetMenuItemInfo(hSubMenu, j - 1, true, mii);
} else {
mii.fMask = MIIM_ID | MIIM_FTYPE;
for (var k = 0; k < api.GetMenuItemCount(hSubMenu); k++) {
api.GetMenuItemInfo(hSubMenu, k, true, mii);
if (mii.fType & MFT_SEPARATOR) {
mii.wID = wID;
break;
}
wID = mii.wID;
}
}
if (mii.wID > 0) {
ContextMenu.InvokeCommand(0, te.hwnd, mii.wID - 1, null, null, SW_SHOWNORMAL, 0, 0);
}
break;
}
}
break;
}
}
api.DestroyMenu(hMenu);
}
}
@tablacus
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment