Author: gadamopoulos
Date: Mon Mar 30 12:21:39 2015
New Revision: 66979
URL:
http://svn.reactos.org/svn/reactos?rev=66979&view=rev
Log:
[SHELL32]
- CDefView: Use SHForwardContextMenuMsg to forward menu messages to the context menu
class
- CDefaultContextMenu: Implement IContextMenu3 and use SHForwardContextMenuMsg to forward
menu messages to shell extensions.
CORE-9446 (part 2/2)
Modified:
trunk/reactos/dll/win32/shell32/CDefView.cpp
trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp
Modified: trunk/reactos/dll/win32/shell32/CDefView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CDefView…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] Mon Mar 30 12:21:39 2015
@@ -1942,12 +1942,9 @@
return FALSE;
}
- CComPtr<IContextMenu2> pCM2;
- HRESULT hres = m_pCM.p->QueryInterface(IID_PPV_ARG(IContextMenu2, &pCM2));
- if(FAILED(hres))
- return FALSE;
-
- if (pCM2.p->HandleMenuMsg(uMsg, (WPARAM)m_hWnd, lParam) == S_OK)
+ LRESULT result;
+ HRESULT hres = SHForwardContextMenuMsg(m_pCM, uMsg, wParam, lParam, &result,
TRUE);
+ if (SUCCEEDED(hres))
return TRUE;
else
return FALSE;
Modified: trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CDefault…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp [iso-8859-1] Mon Mar 30
12:21:39 2015
@@ -34,7 +34,7 @@
class CDefaultContextMenu :
public CComObjectRootEx<CComMultiThreadModelNoCS>,
- public IContextMenu2
+ public IContextMenu3
{
private:
CComPtr<IShellFolder> m_psf;
@@ -74,6 +74,7 @@
DWORD BrowserFlagsFromVerb(LPCMINVOKECOMMANDINFO lpcmi, PStaticShellEntry
pEntry);
HRESULT TryToBrowse(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, DWORD
wFlags);
HRESULT InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl,
PStaticShellEntry pEntry);
+ PDynamicShellEntry GetDynamicEntry(UINT idCmd);
public:
CDefaultContextMenu();
@@ -88,9 +89,13 @@
// IContextMenu2
virtual HRESULT WINAPI HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ // IContextMenu3
+ virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam,
LRESULT *plResult);
+
BEGIN_COM_MAP(CDefaultContextMenu)
COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2)
+ COM_INTERFACE_ENTRY_IID(IID_IContextMenu3, IContextMenu3)
END_COM_MAP()
};
@@ -1347,29 +1352,36 @@
return S_OK;
}
+PDynamicShellEntry CDefaultContextMenu::GetDynamicEntry(UINT idCmd)
+{
+ PDynamicShellEntry pEntry = m_pDynamicEntries;
+
+ while(pEntry && idCmd > pEntry->iIdCmdFirst + pEntry->NumIds)
+ pEntry = pEntry->pNext;
+
+ if (!pEntry)
+ return NULL;
+
+ if (idCmd < pEntry->iIdCmdFirst || idCmd > pEntry->iIdCmdFirst +
pEntry->NumIds)
+ return NULL;
+
+ return pEntry;
+}
+
HRESULT
CDefaultContextMenu::DoDynamicShellExtensions(
LPCMINVOKECOMMANDINFO lpcmi)
-{
+{
+ TRACE("verb %p first %x last %x", lpcmi->lpVerb, m_iIdSHEFirst,
m_iIdSHELast);
+
UINT idCmd = LOWORD(lpcmi->lpVerb);
- PDynamicShellEntry pEntry = m_pDynamicEntries;
-
- TRACE("verb %p first %x last %x", lpcmi->lpVerb, m_iIdSHEFirst,
m_iIdSHELast);
-
- while(pEntry && idCmd > pEntry->iIdCmdFirst + pEntry->NumIds)
- pEntry = pEntry->pNext;
-
+ PDynamicShellEntry pEntry = GetDynamicEntry(idCmd);
if (!pEntry)
return E_FAIL;
- if (idCmd >= pEntry->iIdCmdFirst && idCmd <= pEntry->iIdCmdFirst
+ pEntry->NumIds)
- {
- /* invoke the dynamic context menu */
- lpcmi->lpVerb = MAKEINTRESOURCEA(idCmd - pEntry->iIdCmdFirst);
- return pEntry->pCM->InvokeCommand(lpcmi);
- }
-
- return E_FAIL;
+ /* invoke the dynamic context menu */
+ lpcmi->lpVerb = MAKEINTRESOURCEA(idCmd - pEntry->iIdCmdFirst);
+ return pEntry->pCM->InvokeCommand(lpcmi);
}
DWORD
@@ -1594,7 +1606,53 @@
WPARAM wParam,
LPARAM lParam)
{
+ /* FIXME: Should we implement this as well? */
return S_OK;
+}
+
+HRESULT
+WINAPI
+CDefaultContextMenu::HandleMenuMsg2(
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam,
+ LRESULT *plResult)
+{
+ switch (uMsg)
+ {
+ case WM_INITMENUPOPUP:
+ {
+ PDynamicShellEntry pEntry = m_pDynamicEntries;
+ while (pEntry)
+ {
+ SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult,
TRUE);
+ pEntry = pEntry->pNext;
+ }
+ break;
+ }
+ case WM_DRAWITEM:
+ {
+ DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
+ PDynamicShellEntry pEntry = GetDynamicEntry(pDrawStruct->itemID);
+ if(pEntry)
+ SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult,
TRUE);
+ break;
+ }
+ case WM_MEASUREITEM:
+ {
+ MEASUREITEMSTRUCT* pMeasureStruct =
reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
+ PDynamicShellEntry pEntry = GetDynamicEntry(pMeasureStruct->itemID);
+ if(pEntry)
+ SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult,
TRUE);
+ break;
+ }
+ case WM_MENUCHAR :
+ /* FIXME */
+ break;
+ default:
+ ERR("Got unknown message:%d\n", uMsg);
+ }
+ return S_OK;
}
static