Author: dquintana Date: Thu Dec 4 19:53:02 2014 New Revision: 65560
URL: http://svn.reactos.org/svn/reactos?rev=65560&view=rev Log: [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
Modified: trunk/reactos/base/shell/explorer/tbsite.cpp trunk/reactos/base/shell/explorer/traywnd.cpp
Modified: trunk/reactos/base/shell/explorer/tbsite.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/tbsite.... ============================================================================== --- trunk/reactos/base/shell/explorer/tbsite.cpp [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/tbsite.cpp [iso-8859-1] Thu Dec 4 19:53:02 2014 @@ -288,11 +288,11 @@ 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,13 +302,10 @@ 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 @@ }
/* Add the menu items */ - return ContextMenu->QueryContextMenu( - hmenu, - indexMenu, - idCmdFirst, - idCmdLast, - uFlags); + return ContextMenu->QueryContextMenu(hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags); }
virtual HRESULT STDMETHODCALLTYPE Lock(
Modified: trunk/reactos/base/shell/explorer/traywnd.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/traywnd... ============================================================================== --- trunk/reactos/base/shell/explorer/traywnd.cpp [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/traywnd.cpp [iso-8859-1] Thu Dec 4 19:53:02 2014 @@ -3029,59 +3029,59 @@ { HMENU menubase = LoadPopupMenu(hExplorerInstance, MAKEINTRESOURCE(IDM_TRAYWND));
- if (menubase) - { - int count = ::GetMenuItemCount(menubase); - - 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); - - 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; - } - } - - } - - return E_FAIL; + if (!menubase) + return HRESULT_FROM_WIN32(GetLastError()); + + int count = ::GetMenuItemCount(menubase); + + 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); + + 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 (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