[EXPLORER]

* Reorganize a bit the CTrayWindowCtxMenu::QueryContextMenu method and do not error if AddContextMenus fails. Fixes the taskbar context menu not opening on right-click.
(No need to call it explorer-new now that it's the primary one!)
CORE-8838

svn path=/trunk/; revision=65560
This commit is contained in:
David Quintana 2014-12-04 19:53:02 +00:00
parent be4775c2b8
commit 96d86fca58
2 changed files with 50 additions and 58 deletions

View file

@ -288,11 +288,11 @@ public:
IN UINT uFlags,
OUT IContextMenu **ppcm)
{
IShellService *pSs;
HRESULT hRet;
if (ContextMenu == NULL)
{
HRESULT hRet;
CComPtr<IShellService> pSs;
/* Cache the context menu so we don't need to CoCreateInstance all the time... */
hRet = CoCreateInstance(CLSID_BandSiteMenu, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellService, &pSs));
TRACE("CoCreateInstance(CLSID_BandSiteMenu) for IShellService returned: 0x%x\n", hRet);
@ -302,14 +302,11 @@ public:
hRet = pSs->SetOwner((IBandSite*)this);
if (!SUCCEEDED(hRet))
{
pSs->Release();
return hRet;
}
hRet = pSs->QueryInterface(IID_PPV_ARG(IContextMenu, &ContextMenu));
pSs->Release();
if (!SUCCEEDED(hRet))
return hRet;
}
@ -321,12 +318,7 @@ public:
}
/* Add the menu items */
return ContextMenu->QueryContextMenu(
hmenu,
indexMenu,
idCmdFirst,
idCmdLast,
uFlags);
return ContextMenu->QueryContextMenu(hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
}
virtual HRESULT STDMETHODCALLTYPE Lock(

View file

@ -3029,59 +3029,59 @@ public:
{
HMENU menubase = LoadPopupMenu(hExplorerInstance, MAKEINTRESOURCE(IDM_TRAYWND));
if (menubase)
if (!menubase)
return HRESULT_FROM_WIN32(GetLastError());
int count = ::GetMenuItemCount(menubase);
for (int i = 0; i < count; i++)
{
int count = ::GetMenuItemCount(menubase);
WCHAR label[128];
for (int i = 0; i < count; i++)
{
WCHAR label[128];
MENUITEMINFOW mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS
| MIIM_DATA | MIIM_STRING | MIIM_BITMAP | MIIM_FTYPE;
mii.dwTypeData = label;
mii.cch = _countof(label);
::GetMenuItemInfoW(menubase, i, TRUE, &mii);
MENUITEMINFOW mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS
| MIIM_DATA | MIIM_STRING | MIIM_BITMAP | MIIM_FTYPE;
mii.dwTypeData = label;
mii.cch = _countof(label);
::GetMenuItemInfoW(menubase, i, TRUE, &mii);
TRACE("Adding item %d label %S type %d\n", mii.wID, mii.dwTypeData, mii.fType);
TRACE("Adding item %d label %S type %d\n", mii.wID, mii.dwTypeData, mii.fType);
mii.fType |= MFT_RADIOCHECK;
::InsertMenuItemW(hPopup, i + 1, TRUE, &mii);
}
::DestroyMenu(menubase);
if (SHRestricted(REST_CLASSICSHELL) != 0)
{
DeleteMenu(hPopup,
ID_LOCKTASKBAR,
MF_BYCOMMAND);
}
CheckMenuItem(hPopup,
ID_LOCKTASKBAR,
MF_BYCOMMAND | (TrayWnd->Locked ? MF_CHECKED : MF_UNCHECKED));
if (TrayWnd->TrayBandSite != NULL)
{
if (SUCCEEDED(TrayWnd->TrayBandSite->AddContextMenus(
hPopup,
0,
ID_SHELL_CMD_FIRST,
ID_SHELL_CMD_LAST,
CMF_NORMAL,
&pcm)))
{
return S_OK;
}
}
mii.fType |= MFT_RADIOCHECK;
::InsertMenuItemW(hPopup, i + 1, TRUE, &mii);
}
return E_FAIL;
::DestroyMenu(menubase);
if (SHRestricted(REST_CLASSICSHELL) != 0)
{
DeleteMenu(hPopup,
ID_LOCKTASKBAR,
MF_BYCOMMAND);
}
CheckMenuItem(hPopup,
ID_LOCKTASKBAR,
MF_BYCOMMAND | (TrayWnd->Locked ? MF_CHECKED : MF_UNCHECKED));
if (TrayWnd->TrayBandSite != NULL)
{
if (FAILED(TrayWnd->TrayBandSite->AddContextMenus(
hPopup,
0,
ID_SHELL_CMD_FIRST,
ID_SHELL_CMD_LAST,
CMF_NORMAL,
&pcm)))
{
WARN("AddContextMenus failed.\n");
pcm = NULL;
}
}
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE