https://git.reactos.org/?p=reactos.git;a=commitdiff;h=484f33f0d3bcf339f0eb2…
commit 484f33f0d3bcf339f0eb287cd9673459cd964897
Author: Stas'M <x86corez(a)gmail.com>
AuthorDate: Wed Nov 1 23:05:33 2017 +0300
[BROWSEUI] CBandSiteMenu
- Move SHGetFolder code to CreateBuiltInISFBand
- Get rid of CSIDL_FLAG_CREATE (Windows doesn't create Quick Launch
directory)
- Use ILFree since variables are reused now
---
dll/win32/browseui/shellbars/CBandSiteMenu.cpp | 62 +++++++++++++++++++-------
dll/win32/browseui/shellbars/CBandSiteMenu.h | 1 +
2 files changed, 48 insertions(+), 15 deletions(-)
diff --git a/dll/win32/browseui/shellbars/CBandSiteMenu.cpp
b/dll/win32/browseui/shellbars/CBandSiteMenu.cpp
index ea0f9cf9b6..0c56af463c 100644
--- a/dll/win32/browseui/shellbars/CBandSiteMenu.cpp
+++ b/dll/win32/browseui/shellbars/CBandSiteMenu.cpp
@@ -48,19 +48,6 @@ CBandSiteMenu::~CBandSiteMenu()
HRESULT WINAPI CBandSiteMenu::FinalConstruct()
{
- HRESULT hr = SHGetFolderLocation(0, CSIDL_DESKTOP, NULL, 0, &m_DesktopPidl);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- WCHAR buffer[MAX_PATH];
- hr = SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0,
L"Microsoft\\Internet Explorer\\Quick Launch", buffer);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- m_QLaunchPidl.Attach(ILCreateFromPathW(buffer));
- if (m_QLaunchPidl == NULL)
- return E_FAIL;
-
return S_OK;
}
@@ -150,12 +137,53 @@ HRESULT CBandSiteMenu::_CreateNewISFBand(HWND hwnd, REFIID riid,
void** ppv)
return pISFB->QueryInterface(riid, ppv);
}
+LPITEMIDLIST CBandSiteMenu::_GetQLaunchPidl(BOOL refresh)
+{
+ if (m_QLaunchPidl != NULL)
+ {
+ if (refresh)
+ m_QLaunchPidl.Free();
+ else
+ return m_QLaunchPidl;
+ }
+
+ WCHAR buffer[MAX_PATH];
+ HRESULT hr = SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA, NULL, 0,
L"Microsoft\\Internet Explorer\\Quick Launch", buffer);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return NULL;
+
+ m_QLaunchPidl.Attach(ILCreateFromPathW(buffer));
+ return m_QLaunchPidl;
+}
+
HRESULT CBandSiteMenu::_CreateBuiltInISFBand(UINT uID, REFIID riid, void** ppv)
{
LPITEMIDLIST pidl;
HRESULT hr;
- pidl = (uID == IDM_TASKBAR_TOOLBARS_DESKTOP) ? m_DesktopPidl : m_QLaunchPidl;
+ switch (uID)
+ {
+ case IDM_TASKBAR_TOOLBARS_DESKTOP:
+ {
+ if (m_DesktopPidl != NULL)
+ m_DesktopPidl.Free();
+
+ hr = SHGetFolderLocation(0, CSIDL_DESKTOP, NULL, 0, &m_DesktopPidl);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ pidl = m_DesktopPidl;
+ break;
+ }
+ case IDM_TASKBAR_TOOLBARS_QUICKLAUNCH:
+ {
+ pidl = _GetQLaunchPidl(true);
+ break;
+ }
+ }
+
+ if (pidl == NULL)
+ return E_FAIL;
CComPtr<IShellFolderBand> pISFB;
hr = CISFBand_CreateInstance(IID_IShellFolderBand, (PVOID*)&pISFB);
@@ -238,7 +266,11 @@ UINT CBandSiteMenu::_GetMenuIdFromISFBand(IUnknown *pBand)
if (FAILED_UNEXPECTEDLY(hr))
return UINT_MAX;
- hr = psfDesktop->CompareIDs(0, pidl, m_QLaunchPidl);
+ LPITEMIDLIST _QLaunchPidl = _GetQLaunchPidl(false);
+ if (_QLaunchPidl == NULL)
+ return UINT_MAX;
+
+ hr = psfDesktop->CompareIDs(0, pidl, _QLaunchPidl);
if (FAILED_UNEXPECTEDLY(hr))
return UINT_MAX;
diff --git a/dll/win32/browseui/shellbars/CBandSiteMenu.h
b/dll/win32/browseui/shellbars/CBandSiteMenu.h
index 6a78ae7c54..4e56fa998f 100644
--- a/dll/win32/browseui/shellbars/CBandSiteMenu.h
+++ b/dll/win32/browseui/shellbars/CBandSiteMenu.h
@@ -36,6 +36,7 @@ class CBandSiteMenu :
HRESULT _CreateMenuPart();
HRESULT _CreateNewISFBand(HWND hwnd, REFIID riid, void** ppv);
+ LPITEMIDLIST _GetQLaunchPidl(BOOL refresh);
HRESULT _CreateBuiltInISFBand(UINT uID, REFIID riid, void** ppv);
HRESULT _AddISFBandToMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT
idCmdLast, IUnknown* pBand, DWORD dwBandID, UINT *newMenuId);
UINT _GetMenuIdFromISFBand(IUnknown *pBand);