[BROWSEUI]
authorDavid Quintana <gigaherz@gmail.com>
Wed, 29 Oct 2014 22:28:51 +0000 (22:28 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Wed, 29 Oct 2014 22:28:51 +0000 (22:28 +0000)
* Allow the static items in the Favorites menu to be received by the shell browse window.
* Handle the Organize Favorites menu item by opening either the USER favorites, or the COMMON version of the folder.

[RSHELL]
* Send the proper HWND together with the HMENU, when sending callbacks.

svn path=/branches/shell-experiments/; revision=65111

base/shell/explorer-new/traywnd.c
base/shell/rshell/CMenuBand.cpp
base/shell/rshell/CMenuToolbars.cpp
base/shell/rshell/CMenuToolbars.h
base/shell/rshell/precomp.h
dll/win32/browseui/internettoolbar.cpp
dll/win32/browseui/shellbrowser.cpp
include/reactos/undocshell.h

index 77c3c97..e770823 100644 (file)
@@ -2929,7 +2929,7 @@ HandleTrayContextMenu:
                         {
                             /* TODO: Implement properly */
 
                         {
                             /* TODO: Implement properly */
 
-                            LPCWSTR strSite = L"http://www.reactos.org/";
+                            LPCWSTR strSite = L"https://www.reactos.org/";
 
                             /* TODO: Make localizable */
                             LPCWSTR strCaption = L"Sorry";
 
                             /* TODO: Make localizable */
                             LPCWSTR strCaption = L"Sorry";
index a9979b9..29ba8a3 100644 (file)
@@ -738,18 +738,14 @@ HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id, LPI
     if (!m_psmc)
         return S_FALSE;
 
     if (!m_psmc)
         return S_FALSE;
 
-    HWND hwnd;
-    GetWindow(&hwnd);
-
     SMDATA smData = { 0 };
     smData.punk = static_cast<IShellMenu2*>(this);
     smData.uId = id;
     smData.uIdParent = m_uId;
     smData.uIdAncestor = m_uIdAncestor;
     smData.pidlItem = pidl;
     SMDATA smData = { 0 };
     smData.punk = static_cast<IShellMenu2*>(this);
     smData.uId = id;
     smData.uIdParent = m_uId;
     smData.uIdAncestor = m_uIdAncestor;
     smData.pidlItem = pidl;
-    smData.hwnd = hwnd;
-    if (m_hmenu)
-        smData.hmenu = m_hmenu;
+    smData.hwnd = m_menuOwner ? m_menuOwner : m_topLevelWindow;
+    smData.hmenu = m_hmenu;
     smData.pvUserData = NULL;
     if (m_SFToolbar)
         m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
     smData.pvUserData = NULL;
     if (m_SFToolbar)
         m_SFToolbar->GetShellFolder(NULL, &smData.pidlFolder, IID_PPV_ARG(IShellFolder, &smData.psf));
index aa879a2..32b17e9 100644 (file)
@@ -1111,7 +1111,8 @@ HRESULT CMenuToolbarBase::PopupItem(INT iItem, BOOL keyInitiated)
 
 CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) :
     CMenuToolbarBase(menuBand, FALSE),
 
 CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) :
     CMenuToolbarBase(menuBand, FALSE),
-    m_hmenu(NULL)
+    m_hmenu(NULL),
+    m_hwndMenu(NULL)
 {
 }
 
 {
 }
 
@@ -1127,7 +1128,7 @@ HRESULT  CMenuStaticToolbar::GetMenu(
     if (phmenu)
         *phmenu = m_hmenu;
     if (phwnd)
     if (phmenu)
         *phmenu = m_hmenu;
     if (phwnd)
-        *phwnd = NULL;
+        *phwnd = m_hwndMenu;
     if (pdwFlags)
         *pdwFlags = m_dwMenuFlags;
 
     if (pdwFlags)
         *pdwFlags = m_dwMenuFlags;
 
@@ -1140,6 +1141,7 @@ HRESULT  CMenuStaticToolbar::SetMenu(
     DWORD dwFlags)
 {
     m_hmenu = hmenu;
     DWORD dwFlags)
 {
     m_hmenu = hmenu;
+    m_hwndMenu = hwnd;
     m_dwMenuFlags = dwFlags;
 
     return S_OK;
     m_dwMenuFlags = dwFlags;
 
     return S_OK;
index 86ad44f..353e63b 100644 (file)
@@ -137,6 +137,7 @@ class CMenuStaticToolbar :
 {
 private:
     HMENU m_hmenu;
 {
 private:
     HMENU m_hmenu;
+    HWND m_hwndMenu;
 
 public:
     CMenuStaticToolbar(CMenuBand *menuBand);
 
 public:
     CMenuStaticToolbar(CMenuBand *menuBand);
index c1d1fee..4245975 100644 (file)
@@ -68,8 +68,6 @@
 #endif
 
 #define shell32_hInstance 0
 #endif
 
 #define shell32_hInstance 0
-#define SMC_EXEC 4
-extern "C" INT WINAPI Shell_GetCachedImageIndex(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc);
 
 extern "C" HRESULT WINAPI CStartMenu_Constructor(REFIID riid, void **ppv);
 extern "C" HRESULT WINAPI CMenuDeskBar_Constructor(REFIID riid, LPVOID *ppv);
 
 extern "C" HRESULT WINAPI CStartMenu_Constructor(REFIID riid, void **ppv);
 extern "C" HRESULT WINAPI CMenuDeskBar_Constructor(REFIID riid, LPVOID *ppv);
index 1ab30a7..b7803c7 100644 (file)
@@ -646,6 +646,9 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::CallbackSM(LPSMDATA psmd, UINT uMsg, WP
             return GetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam));
         case SMC_GETSFOBJECT:
             break;
             return GetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam));
         case SMC_GETSFOBJECT:
             break;
+        case SMC_EXEC:
+            PostMessageW(psmd->hwnd, WM_COMMAND, psmd->uId, 0);
+            break;
         case SMC_SFEXEC:
             SHInvokeDefaultCommand(psmd->hwnd, psmd->psf, psmd->pidlItem);
             break;
         case SMC_SFEXEC:
             SHInvokeDefaultCommand(psmd->hwnd, psmd->psf, psmd->pidlItem);
             break;
index 63f3271..94920c7 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <shellapi.h>
 #include <htiframe.h>
 
 #include <shellapi.h>
 #include <htiframe.h>
+#include <strsafe.h>
 
 extern "C"
 BOOL WINAPI Shell_GetImageLists(
 
 extern "C"
 BOOL WINAPI Shell_GetImageLists(
@@ -633,6 +634,7 @@ public:
     LRESULT OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnIsThisLegal(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnGoHome(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnIsThisLegal(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
+    LRESULT OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnToggleToolbarLock(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnToggleToolbarBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnToggleStatusBarVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnToggleToolbarLock(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
     LRESULT OnToggleToolbarBandVisible(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
@@ -672,6 +674,7 @@ public:
         COMMAND_ID_HANDLER(IDM_GOTO_FORWARD, OnGoForward)
         COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnGoUpLevel)
         COMMAND_ID_HANDLER(IDM_GOTO_HOMEPAGE, OnGoHome)
         COMMAND_ID_HANDLER(IDM_GOTO_FORWARD, OnGoForward)
         COMMAND_ID_HANDLER(IDM_GOTO_UPONELEVEL, OnGoUpLevel)
         COMMAND_ID_HANDLER(IDM_GOTO_HOMEPAGE, OnGoHome)
+        COMMAND_ID_HANDLER(IDM_FAVORITES_ORGANIZEFAVORITES, OnOrganizeFavorites)
         COMMAND_ID_HANDLER(IDM_HELP_ISTHISCOPYLEGAL, OnIsThisLegal)
         COMMAND_ID_HANDLER(IDM_VIEW_STATUSBAR, OnToggleStatusBarVisible)
         COMMAND_ID_HANDLER(IDM_TOOLBARS_LOCKTOOLBARS, OnToggleToolbarLock)
         COMMAND_ID_HANDLER(IDM_HELP_ISTHISCOPYLEGAL, OnIsThisLegal)
         COMMAND_ID_HANDLER(IDM_VIEW_STATUSBAR, OnToggleStatusBarVisible)
         COMMAND_ID_HANDLER(IDM_TOOLBARS_LOCKTOOLBARS, OnToggleToolbarLock)
@@ -1871,7 +1874,7 @@ HRESULT STDMETHODCALLTYPE CShellBrowser::SetMenuSB(HMENU hmenuShared, HOLEMENU h
     hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
     hResult = GetMenuBand(IID_PPV_ARG(IShellMenu, &shellMenu));
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
-    hResult = shellMenu->SetMenu(hmenuShared, NULL, SMSET_DONTOWN);
+    hResult = shellMenu->SetMenu(hmenuShared, m_hWnd, SMSET_DONTOWN);
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
     fCurrentMenuBar = hmenuShared;
     if (FAILED_UNEXPECTEDLY(hResult))
         return hResult;
     fCurrentMenuBar = hmenuShared;
@@ -3252,9 +3255,54 @@ LRESULT CShellBrowser::OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
     return 0;
 }
 
     return 0;
 }
 
+LRESULT CShellBrowser::OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
+{
+    CComPtr<IShellFolder> psfDesktop;
+    LPITEMIDLIST pidlFavs;
+    HRESULT hr;
+    hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_FAVORITES, &pidlFavs);
+    if (FAILED(hr))
+    {
+        hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_COMMON_FAVORITES, &pidlFavs);
+        if (FAILED(hr))
+            return 0;
+    }
+
+    hr = SHGetDesktopFolder(&psfDesktop);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return 0;
+
+    hr = SHInvokeDefaultCommand(m_hWnd, psfDesktop, pidlFavs);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return 0;
+
+    return 0;
+}
+
 LRESULT CShellBrowser::OnIsThisLegal(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 {
 LRESULT CShellBrowser::OnIsThisLegal(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
 {
-    ShellExecute(m_hWnd, NULL, L"https://reactos.org/user-faq", NULL, NULL, SW_SHOWNORMAL);
+    /* TODO: Implement properly */
+
+    LPCWSTR strSite = L"https://www.reactos.org/user-faq";
+
+    /* TODO: Make localizable */
+    LPCWSTR strCaption = L"Sorry";
+    LPCWSTR strMessage = L"ReactOS could not browse to '%s' (error %d). Please make sure there is a web browser installed.";
+    WCHAR tmpMessage[512];
+
+    /* TODO: Read from the registry */
+    LPCWSTR strVerb = NULL; /* default */
+    LPCWSTR strPath = strSite;
+    LPCWSTR strParams = NULL;
+
+    /* The return value is defined as HINSTANCE for backwards compatibility only, the cast is needed */
+    int result = (int) ShellExecuteW(m_hWnd, strVerb, strPath, strParams, NULL, SW_SHOWNORMAL);
+    if (result <= 32)
+    {
+        StringCchPrintfW(tmpMessage, 512, strMessage, strSite, result);
+        MessageBoxExW(m_hWnd, tmpMessage, strCaption, MB_OK, 0);
+    }
+
     return 0;
 }
 
     return 0;
 }
 
index 5b1e785..2dee756 100644 (file)
@@ -532,6 +532,9 @@ BOOL WINAPI SHDesktopMessageLoop(HANDLE);
 /* Utility functions */
 #include <stdio.h>
 
 /* Utility functions */
 #include <stdio.h>
 
+#define SMC_EXEC 4
+extern "C" INT WINAPI Shell_GetCachedImageIndex(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc);
+
 static inline ULONG
 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
 {
 static inline ULONG
 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
 {