[SHELL32] Respect menu Ctrl/Shift in CMenuBand and SHBrowseForFolder (#7015)

This commit is contained in:
Whindmar Saksit 2024-06-13 13:11:34 +02:00 committed by GitHub
parent d73a838245
commit 7c3d3851b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -911,8 +911,6 @@ BrFolder_OnContextMenu(BrFolder &info, LPARAM lParam)
enum { IDC_TOGGLE = 1, ID_FIRSTCMD, ID_LASTCMD = 0xffff };
HTREEITEM hSelected = TreeView_GetSelection(info.hwndTreeView);
CMINVOKECOMMANDINFOEX ici = { sizeof(ici), CMIC_MASK_PTINVOKE, info.hWnd };
ici.fMask |= (GetKeyState(VK_SHIFT) < 0) ? CMIC_MASK_SHIFT_DOWN : 0;
ici.fMask |= (GetKeyState(VK_CONTROL) < 0) ? CMIC_MASK_CONTROL_DOWN : 0;
ici.nShow = SW_SHOW;
ici.ptInvoke.x = GET_X_LPARAM(lParam);
ici.ptInvoke.y = GET_Y_LPARAM(lParam);
@ -946,7 +944,7 @@ BrFolder_OnContextMenu(BrFolder &info, LPARAM lParam)
if (!hMenu)
return;
info.pContextMenu = pcm;
UINT cmf = ((ici.fMask & CMIC_MASK_SHIFT_DOWN) ? CMF_EXTENDEDVERBS : 0) | CMF_CANRENAME;
UINT cmf = ((GetKeyState(VK_SHIFT) < 0) ? CMF_EXTENDEDVERBS : 0) | CMF_CANRENAME;
hr = pcm->QueryContextMenu(hMenu, 0, ID_FIRSTCMD, ID_LASTCMD, CMF_NODEFAULT | cmf);
if (hr > 0)
_InsertMenuItemW(hMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, 0);
@ -968,6 +966,10 @@ BrFolder_OnContextMenu(BrFolder &info, LPARAM lParam)
}
else if (cmd != 0)
{
if (GetKeyState(VK_SHIFT) < 0)
ici.fMask |= CMIC_MASK_SHIFT_DOWN;
if (GetKeyState(VK_CONTROL) < 0)
ici.fMask |= CMIC_MASK_CONTROL_DOWN;
pcm->InvokeCommand((CMINVOKECOMMANDINFO*)&ici);
}
info.pContextMenu = NULL;

View File

@ -832,8 +832,12 @@ HRESULT CMenuBand::_TrackContextMenu(IContextMenu * contextMenu, INT x, INT y)
return E_FAIL;
TRACE("Before Query\n");
const INT idCmdFirst = 100;
hr = contextMenu->QueryContextMenu(popup, 0, idCmdFirst, UINT_MAX, CMF_NORMAL);
UINT cmf = CMF_NORMAL;
if (GetKeyState(VK_SHIFT) < 0)
cmf |= CMF_EXTENDEDVERBS;
const UINT idCmdFirst = 100, idCmdLast = 0xffff;
hr = contextMenu->QueryContextMenu(popup, 0, idCmdFirst, idCmdLast, cmf);
if (FAILED_UNEXPECTEDLY(hr))
{
TRACE("Query failed\n");
@ -857,6 +861,10 @@ HRESULT CMenuBand::_TrackContextMenu(IContextMenu * contextMenu, INT x, INT y)
TRACE("Before InvokeCommand\n");
CMINVOKECOMMANDINFO cmi = { sizeof(cmi), 0, hwnd };
cmi.lpVerb = MAKEINTRESOURCEA(uCommand - idCmdFirst);
if (GetKeyState(VK_SHIFT) < 0)
cmi.fMask |= CMIC_MASK_SHIFT_DOWN;
if (GetKeyState(VK_CONTROL) < 0)
cmi.fMask |= CMIC_MASK_CONTROL_DOWN;
hr = contextMenu->InvokeCommand(&cmi);
TRACE("InvokeCommand returned hr=%08x\n", hr);
}