Author: dquintana
Date: Sat Aug 9 15:56:05 2014
New Revision: 63847
URL:
http://svn.reactos.org/svn/reactos?rev=63847&view=rev
Log:
[BROWSEUI]
* Fix usage of outdated CMergedFolder to use the proper interface.
Modified:
branches/shell-experiments/base/shell/rshell/CStartMenu.cpp
branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp
branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp
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] Sat Aug 9
15:56:05 2014
@@ -21,6 +21,7 @@
#include "CMergedFolder.h"
+// TODO: declare these GUIDs and interfaces in the right place (whatever that may be)
IID IID_IAugmentedShellFolder = { 0x91EA3F8C, 0xC99B, 0x11D0, { 0x98, 0x15, 0x00, 0xC0,
0x4F, 0xD9, 0x19, 0x72 } };
IID IID_IAugmentedShellFolder2 = { 0x8DB3B3F4, 0x6CFE, 0x11D1, { 0x8A, 0xE9, 0x00, 0xC0,
0x4F, 0xD9, 0x18, 0xD0 } };
CLSID CLSID_MergedFolder = { 0x26FDC864, 0xBE88, 0x46E7, { 0x92, 0x35, 0x03, 0x2D, 0x8E,
0xA5, 0x16, 0x2E } };
@@ -309,7 +310,7 @@
return hr;
}
-HRESULT GetStartMenuFolder(IShellFolder ** ppsfStartMenu)
+static HRESULT GetStartMenuFolder(IShellFolder ** ppsfStartMenu)
{
HRESULT hr;
LPITEMIDLIST pidlUserStartMenu;
Modified: branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp [iso-8859-1] Sat Aug
9 15:56:05 2014
@@ -30,6 +30,22 @@
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#define USE_CUSTOM_MENUBAND 1
+
+#if 1
+// TODO: declare these GUIDs and interfaces in the right place (whatever that may be)
+
+IID IID_IAugmentedShellFolder = { 0x91EA3F8C, 0xC99B, 0x11D0, { 0x98, 0x15, 0x00, 0xC0,
0x4F, 0xD9, 0x19, 0x72 } };
+CLSID CLSID_MergedFolder = { 0x26FDC864, 0xBE88, 0x46E7, { 0x92, 0x35, 0x03, 0x2D, 0x8E,
0xA5, 0x16, 0x2E } };
+
+interface IAugmentedShellFolder : public IShellFolder
+{
+ virtual HRESULT STDMETHODCALLTYPE AddNameSpace(LPGUID, IShellFolder *, LPCITEMIDLIST,
ULONG) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetNameSpaceID(LPCITEMIDLIST, LPGUID) = 0;
+ virtual HRESULT STDMETHODCALLTYPE QueryNameSpace(ULONG, LPGUID, IShellFolder **) =
0;
+ virtual HRESULT STDMETHODCALLTYPE EnumNameSpace(ULONG, PULONG) = 0;
+};
+
+#endif
// navigation controls and menubar just send a message to parent window
/*
@@ -74,7 +90,11 @@
extern HRESULT CreateAddressBand(REFIID riid, void **ppv);
typedef HRESULT(WINAPI * PMENUBAND_CONSTRUCTOR)(REFIID riid, void **ppv);
-typedef HRESULT(WINAPI * PMERGEDFOLDER_CONSTRUCTOR)(IShellFolder* userLocal,
IShellFolder* allUsers, REFIID riid, LPVOID *ppv);
+typedef HRESULT(WINAPI * PMERGEDFOLDER_CONSTRUCTOR)(REFIID riid, void **ppv);
+
+HMODULE hRShell = NULL;
+PMERGEDFOLDER_CONSTRUCTOR pCMergedFolder_Constructor = NULL;
+PMENUBAND_CONSTRUCTOR pCMenuBand_Constructor = NULL;
HRESULT IUnknown_HasFocusIO(IUnknown * punk)
{
@@ -392,15 +412,105 @@
{
}
+static HRESULT BindToDesktop(LPCITEMIDLIST pidl, IShellFolder ** ppsfResult)
+{
+ HRESULT hr;
+ CComPtr<IShellFolder> psfDesktop;
+
+ *ppsfResult = NULL;
+
+ hr = SHGetDesktopFolder(&psfDesktop);
+ if (FAILED(hr))
+ return hr;
+
+ hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, ppsfResult));
+
+ return hr;
+}
+
+static HRESULT GetFavoritesFolder(IShellFolder ** ppsfFavorites, LPITEMIDLIST * ppidl)
+{
+ HRESULT hr;
+ LPITEMIDLIST pidlUserFavorites;
+ LPITEMIDLIST pidlCommonFavorites;
+ CComPtr<IShellFolder> psfUserFavorites;
+ CComPtr<IShellFolder> psfCommonFavorites;
+ CComPtr<IAugmentedShellFolder> pasf;
+
+ *ppsfFavorites = NULL;
+
+ hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidlUserFavorites);
+ if (FAILED(hr))
+ return hr;
+
+ if (FAILED(SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_FAVORITES,
&pidlCommonFavorites)))
+ {
+ hr = BindToDesktop(pidlUserFavorites, ppsfFavorites);
+ *ppidl = pidlUserFavorites;
+ return hr;
+ }
+
+ hr = BindToDesktop(pidlUserFavorites, &psfUserFavorites);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ hr = BindToDesktop(pidlCommonFavorites, &psfCommonFavorites);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+#if 1
+ if (!hRShell)
+ {
+ hRShell = GetModuleHandle(L"rshell.dll");
+ if (!hRShell)
+ hRShell = LoadLibrary(L"rshell.dll");
+ }
+
+ if (!pCMergedFolder_Constructor)
+ pCMergedFolder_Constructor = (PMERGEDFOLDER_CONSTRUCTOR) GetProcAddress(hRShell,
"CMergedFolder_Constructor");
+
+ if (pCMergedFolder_Constructor)
+ {
+ hr = pCMergedFolder_Constructor(IID_PPV_ARG(IAugmentedShellFolder, &pasf));
+ }
+ else
+ {
+ hr = E_FAIL;
+ }
+#else
+ hr = CoCreateInstance(CLSID_MergedFolder, NULL, CLSCTX_INPROC_SERVER,
IID_PPV_ARG(IAugmentedShellFolder, &pasf));
+#endif
+ if (FAILED_UNEXPECTEDLY(hr))
+ {
+ *ppsfFavorites = psfUserFavorites.Detach();
+ *ppidl = pidlUserFavorites;
+ ILFree(pidlCommonFavorites);
+ return hr;
+ }
+
+ hr = pasf->AddNameSpace(NULL, psfUserFavorites, pidlUserFavorites, 0xFF00);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ hr = pasf->AddNameSpace(NULL, psfCommonFavorites, pidlCommonFavorites, 0);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ hr = pasf->QueryInterface(IID_PPV_ARG(IShellFolder, ppsfFavorites));
+ pasf.Release();
+
+ ILFree(pidlCommonFavorites);
+ ILFree(pidlUserFavorites);
+
+ return hr;
+}
+
HRESULT STDMETHODCALLTYPE CMenuCallback::GetObject(LPSMDATA psmd, REFIID riid, void
**ppvObject)
{
CComPtr<IShellMenu> parentMenu;
CComPtr<IShellMenu> newMenu;
CComPtr<IShellFolder> favoritesFolder;
LPITEMIDLIST favoritesPIDL;
- CComPtr<IShellFolder> commonFavsFolder;
- LPITEMIDLIST commonFavsPIDL;
- CComPtr<IShellFolder> mergedFolder;
HWND ownerWindow;
HMENU parentHMenu;
HMENU favoritesHMenu;
@@ -428,12 +538,19 @@
if (favoritesHMenu == NULL)
return E_FAIL;
#if USE_CUSTOM_MENUBAND
- HMODULE hrs = LoadLibrary(L"rshell.dll");
-
- PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs,
"CMenuBand_Constructor");
- if (func)
+ if (!hRShell)
{
- hResult = func(IID_PPV_ARG(IShellMenu, &newMenu));
+ hRShell = GetModuleHandle(L"rshell.dll");
+ if (!hRShell)
+ hRShell = LoadLibrary(L"rshell.dll");
+ }
+
+ if (!pCMenuBand_Constructor)
+ pCMenuBand_Constructor = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hRShell,
"CMenuBand_Constructor");
+
+ if (pCMenuBand_Constructor)
+ {
+ hResult = pCMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &newMenu));
}
else
{
@@ -452,36 +569,15 @@
hResult = newMenu->SetMenu(favoritesHMenu, ownerWindow, SMSET_TOP |
SMSET_DONTOWN);
if (FAILED_UNEXPECTEDLY(hResult))
return hResult;
- hResult = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &favoritesPIDL);
- if (FAILED_UNEXPECTEDLY(hResult))
- return hResult;
- hResult = SHBindToFolder(favoritesPIDL, &favoritesFolder);
- if (FAILED_UNEXPECTEDLY(hResult))
- return hResult;
+
RegCreateKeyEx(HKEY_CURRENT_USER, szFavoritesKey,
0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &orderRegKey,
&disposition);
-#if 1 /*USE_MERGED_FAVORITES*/
- hResult = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_FAVORITES,
&commonFavsPIDL);
- if (FAILED_UNEXPECTEDLY(hResult))
- return hResult;
- hResult = SHBindToFolder(commonFavsPIDL, &commonFavsFolder);
- if (FAILED_UNEXPECTEDLY(hResult))
- return hResult;
- ILFree(commonFavsPIDL);
-
- PMERGEDFOLDER_CONSTRUCTOR mfconstruct = (PMERGEDFOLDER_CONSTRUCTOR)
GetProcAddress(hrs, "CMergedFolder_Constructor");
- if (mfconstruct)
- {
- hResult = mfconstruct(favoritesFolder, commonFavsFolder,
IID_PPV_ARG(IShellFolder, &mergedFolder));
- }
- else
- {
- mergedFolder = favoritesFolder;
- }
-#else
- mergedFolder = favoritesFolder;
-#endif
- hResult = newMenu->SetShellFolder(mergedFolder, favoritesPIDL, orderRegKey,
SMSET_BOTTOM | SMINIT_CACHED | SMINV_ID);
+
+ hResult = GetFavoritesFolder(&favoritesFolder, &favoritesPIDL);
+ if (FAILED_UNEXPECTEDLY(hResult))
+ return hResult;
+
+ hResult = newMenu->SetShellFolder(favoritesFolder, favoritesPIDL, orderRegKey,
SMSET_BOTTOM | SMINIT_CACHED | SMINV_ID);
ILFree(favoritesPIDL);
if (SUCCEEDED(hResult))
fFavoritesMenu.Attach(newMenu.Detach());
Modified: branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] Sat Aug 9
15:56:05 2014
@@ -26,13 +26,11 @@
extern "C"
BOOL WINAPI Shell_GetImageLists(
_Out_ HIMAGELIST *phiml,
- _Out_ HIMAGELIST *phimlSmall
- );
+ _Out_ HIMAGELIST *phimlSmall);
extern HRESULT IUnknown_ShowDW(IUnknown * punk, BOOL fShow);
#include "newatlinterfaces.h"
-
/*
TODO:
@@ -1853,16 +1851,7 @@
{
HMENU mainMenu = LoadMenu(_AtlBaseModule.GetResourceInstance(),
MAKEINTRESOURCE(IDM_CABINET_MAINMENU));
- //DbgPrint("Menu from shell32:\n");
- //DbgDumpMenu(hmenuShared);
-
- //DbgPrint("Menu from browseui:\n");
- //DbgDumpMenu(mainMenu);
-
Shell_MergeMenus(hmenuShared, mainMenu, 0, 0, FCIDM_BROWSERLAST,
MM_SUBMENUSHAVEIDS);
-
- //DbgPrint("Merged menu:\n");
- //DbgDumpMenu(hmenuShared);
int GCCU(itemCount3) = GetMenuItemCount(hmenuShared);
Unused(itemCount3);
@@ -1879,9 +1868,6 @@
{
CComPtr<IShellMenu> shellMenu;
HRESULT hResult;
-
- //DbgPrint("SetMenuSB:\n");
- //DbgDumpMenu(hmenuShared);
if (hmenuShared && IsMenu(hmenuShared) == FALSE)
return E_FAIL;
@@ -3206,13 +3192,7 @@
menuIndex = 5;
}
- //DbgPrint("Before relay:\n");
- //DbgDumpMenu(theMenu);
-
LRESULT ret = RelayMsgToShellView(uMsg, wParam, menuIndex, bHandled);
-
- //DbgPrint("After relay:\n");
- //DbgDumpMenu(theMenu);
return ret;
}