Author: dquintana
Date: Mon Feb 17 17:16:55 2014
New Revision: 62231
URL:
http://svn.reactos.org/svn/reactos?rev=62231&view=rev
Log:
[RSHELL]
* CMenuBand: Improve the code structure.
* Make the class selection better managed.
Thanks Giannis.
CORE-7881
Modified:
branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
branches/shell-experiments/base/shell/rshell/CStartMenu.cpp
branches/shell-experiments/base/shell/rshell/precomp.h
Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] Mon Feb 17
17:16:55 2014
@@ -54,6 +54,8 @@
HRESULT OnHotItemChange(const NMTBHOTITEM * hot);
+ HRESULT PopupSubMenu(UINT uItem, IShellMenu* childShellMenu);
+
static LRESULT CALLBACK s_SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam);
protected:
@@ -955,6 +957,72 @@
return S_OK;
}
+HRESULT CMenuToolbarBase::PopupSubMenu(UINT uItem, IShellMenu* childShellMenu)
+{
+ RECT rc;
+ TBBUTTONINFO info = { 0 };
+ info.cbSize = sizeof(TBBUTTONINFO);
+ info.dwMask = 0;
+ int index = SendMessage(m_hwnd, TB_GETBUTTONINFO, uItem, (LPARAM) &info);
+ if (index < 0)
+ return E_FAIL;
+ if (!SendMessage(m_hwnd, TB_GETITEMRECT, index, (LPARAM) &rc))
+ return E_FAIL;
+
+ POINT a = { rc.left, rc.top };
+ POINT b = { rc.right, rc.bottom };
+
+ ClientToScreen(m_hwnd, &a);
+ ClientToScreen(m_hwnd, &b);
+
+ POINTL pt = { b.x, b.y };
+ RECTL rcl = { a.x, a.y, b.x, b.y }; // maybe-TODO: fetch client area of deskbar?
+
+ IBandSite* pBandSite;
+ IDeskBar* pDeskBar;
+
+ HRESULT hr;
+
+#ifndef USE_BUILTIN_MENUSITE
+ hr = CoCreateInstance(CLSID_MenuBandSite,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARG(IBandSite, &pBandSite));
+#else
+ hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite));
+#endif
+ if (FAILED(hr))
+ return hr;
+
+#ifndef USE_BUILTIN_MENUDESKBAR
+ hr = CoCreateInstance(CLSID_MenuDeskBar,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARG(IDeskBar, &pDeskBar));
+#else
+ hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar));
+#endif
+ if (FAILED(hr))
+ return hr;
+
+ hr = pDeskBar->SetClient(pBandSite);
+ if (FAILED(hr))
+ return hr;
+
+ hr = pBandSite->AddBand(childShellMenu);
+ if (FAILED(hr))
+ return hr;
+
+ CComPtr<IMenuPopup> popup;
+ hr = pDeskBar->QueryInterface(IID_PPV_ARG(IMenuPopup, &popup));
+ if (FAILED(hr))
+ return hr;
+
+ popup->Popup(&pt, &rcl, MPPF_TOP | MPPF_RIGHT);
+
+ return S_OK;
+}
+
BOOL
AllocAndGetMenuString(HMENU hMenu, UINT ItemIDByPosition, WCHAR** String)
{
@@ -1058,38 +1126,12 @@
HRESULT CMenuStaticToolbar::PopupItem(UINT uItem)
{
- RECT rc;
- TBBUTTONINFO info = { 0 };
- info.cbSize = sizeof(TBBUTTONINFO);
- info.dwMask = 0;
- int index = SendMessage(m_hwnd, TB_GETBUTTONINFO, uItem, (LPARAM) &info);
- if (index < 0)
- return E_FAIL;
- if (!SendMessage(m_hwnd, TB_GETITEMRECT, index, (LPARAM) &rc))
- return E_FAIL;
-
- POINT a = { rc.left, rc.top };
- POINT b = { rc.right, rc.bottom };
-
- ClientToScreen(m_hwnd, &a);
- ClientToScreen(m_hwnd, &b);
-
- POINTL pt = { b.x, b.y };
- RECTL rcl = { a.x, a.y, b.x, b.y }; // maybe-TODO: fetch client area of deskbar?
-
CComPtr<IShellMenu> shellMenu;
HRESULT hr = m_menuBand->CallCBWithId(uItem, SMC_GETOBJECT, (WPARAM)
&IID_IShellMenu, (LPARAM) &shellMenu);
if (FAILED(hr))
return hr;
- CComPtr<IMenuPopup> popup;
- hr = CSubMenu_Constructor(shellMenu, IID_PPV_ARG(IMenuPopup, &popup));
- if (FAILED(hr))
- return hr;
-
- popup->Popup(&pt, &rcl, MPPF_TOP | MPPF_RIGHT);
-
- return S_OK;
+ return PopupSubMenu(uItem, shellMenu);
}
HRESULT CMenuStaticToolbar::HasSubMenu(UINT uItem)
Modified: branches/shell-experiments/base/shell/rshell/CStartMenu.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] Mon Feb 17
17:16:55 2014
@@ -125,7 +125,7 @@
case IDM_DOCUMENTS: csidl = CSIDL_RECENT; break;
}
-#if 0
+#ifndef USE_BUILTIN_MENUBAND
hr = CoCreateInstance(CLSID_MenuBand,
NULL,
CLSCTX_INPROC_SERVER,
@@ -262,7 +262,7 @@
IShellFolder *shellFolder;
IShellFolder *psfStartMenu;
-#if 0
+#ifndef USE_BUILTIN_MENUBAND
hr = CoCreateInstance(CLSID_MenuBand,
NULL,
CLSCTX_INPROC_SERVER,
@@ -273,7 +273,7 @@
if (FAILED(hr))
return hr;
-#if 0
+#ifndef USE_BUILTIN_MENUSITE
hr = CoCreateInstance(CLSID_MenuBandSite,
NULL,
CLSCTX_INPROC_SERVER,
@@ -284,7 +284,7 @@
if (FAILED(hr))
return hr;
-#if 0
+#ifndef USE_BUILTIN_MENUDESKBAR
hr = CoCreateInstance(CLSID_MenuDeskBar,
NULL,
CLSCTX_INPROC_SERVER,
@@ -325,45 +325,3 @@
return pDeskBar->QueryInterface(riid, ppv);
}
-
-extern "C"
-HRESULT
-CSubMenu_Constructor(IShellMenu * pShellMenu, REFIID riid, void **ppv)
-{
- IBandSite* pBandSite;
- IDeskBar* pDeskBar;
-
- HRESULT hr;
-
-#if 0
- hr = CoCreateInstance(CLSID_MenuBandSite,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_PPV_ARG(IBandSite, &pBandSite));
-#else
- hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite));
-#endif
- if (FAILED(hr))
- return hr;
-
-#if 0
- hr = CoCreateInstance(CLSID_MenuDeskBar,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_PPV_ARG(IDeskBar, &pDeskBar));
-#else
- hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar));
-#endif
- if (FAILED(hr))
- return hr;
-
- hr = pDeskBar->SetClient(pBandSite);
- if (FAILED(hr))
- return hr;
-
- hr = pBandSite->AddBand(pShellMenu);
- if (FAILED(hr))
- return hr;
-
- return pDeskBar->QueryInterface(riid, ppv);
-}
Modified: branches/shell-experiments/base/shell/rshell/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] Mon Feb 17
17:16:55 2014
@@ -1,3 +1,7 @@
+
+#define USE_BUILTIN_MENUDESKBAR
+#define USE_BUILTIN_MENUSITE
+#define USE_BUILTIN_MENUBAND
#include <stdio.h>
#include <tchar.h>
@@ -33,4 +37,3 @@
extern "C" HRESULT CMenuDeskBar_Constructor(REFIID riid, LPVOID *ppv);
extern "C" HRESULT CMenuSite_Constructor(REFIID riid, LPVOID *ppv);
extern "C" HRESULT CMenuBand_Constructor(REFIID riid, LPVOID *ppv);
-extern "C" HRESULT CSubMenu_Constructor(IShellMenu * pShellMenu, REFIID riid,
void **ppv);