Skip to content

Instantly share code, notes, and snippets.

@tablacus
Created August 13, 2017 14:06
Show Gist options
  • Select an option

  • Save tablacus/28107080cf7f7ecada993c7f6583ee32 to your computer and use it in GitHub Desktop.

Select an option

Save tablacus/28107080cf7f7ecada993c7f6583ee32 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;
api.GetMenuItemInfo(hSubMenu, j + 1, true, mii);
if (mii.wID <= 0) {
api.GetMenuItemInfo(hSubMenu, 0, true, mii);
}
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