diff --git a/base/shell/explorer-new/traywnd.c b/base/shell/explorer-new/traywnd.c index 77c3c9735c4..e7708232aac 100644 --- a/base/shell/explorer-new/traywnd.c +++ b/base/shell/explorer-new/traywnd.c @@ -2929,7 +2929,7 @@ HandleTrayContextMenu: { /* TODO: Implement properly */ - LPCWSTR strSite = L"http://www.reactos.org/"; + LPCWSTR strSite = L"https://www.reactos.org/"; /* TODO: Make localizable */ LPCWSTR strCaption = L"Sorry"; diff --git a/base/shell/rshell/CMenuBand.cpp b/base/shell/rshell/CMenuBand.cpp index a9979b95f38..29ba8a3c5ce 100644 --- a/base/shell/rshell/CMenuBand.cpp +++ b/base/shell/rshell/CMenuBand.cpp @@ -738,18 +738,14 @@ HRESULT CMenuBand::_CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam, UINT id, LPI if (!m_psmc) return S_FALSE; - HWND hwnd; - GetWindow(&hwnd); - SMDATA smData = { 0 }; smData.punk = static_cast(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)); diff --git a/base/shell/rshell/CMenuToolbars.cpp b/base/shell/rshell/CMenuToolbars.cpp index aa879a24c2f..32b17e9a346 100644 --- a/base/shell/rshell/CMenuToolbars.cpp +++ b/base/shell/rshell/CMenuToolbars.cpp @@ -1111,7 +1111,8 @@ HRESULT CMenuToolbarBase::PopupItem(INT iItem, BOOL keyInitiated) 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) - *phwnd = NULL; + *phwnd = m_hwndMenu; if (pdwFlags) *pdwFlags = m_dwMenuFlags; @@ -1140,6 +1141,7 @@ HRESULT CMenuStaticToolbar::SetMenu( DWORD dwFlags) { m_hmenu = hmenu; + m_hwndMenu = hwnd; m_dwMenuFlags = dwFlags; return S_OK; diff --git a/base/shell/rshell/CMenuToolbars.h b/base/shell/rshell/CMenuToolbars.h index 86ad44ff227..353e63b3d03 100644 --- a/base/shell/rshell/CMenuToolbars.h +++ b/base/shell/rshell/CMenuToolbars.h @@ -137,6 +137,7 @@ class CMenuStaticToolbar : { private: HMENU m_hmenu; + HWND m_hwndMenu; public: CMenuStaticToolbar(CMenuBand *menuBand); diff --git a/base/shell/rshell/precomp.h b/base/shell/rshell/precomp.h index c1d1fee1816..4245975af27 100644 --- a/base/shell/rshell/precomp.h +++ b/base/shell/rshell/precomp.h @@ -68,8 +68,6 @@ #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); diff --git a/dll/win32/browseui/internettoolbar.cpp b/dll/win32/browseui/internettoolbar.cpp index 1ab30a7fe2e..b7803c7c8e3 100644 --- a/dll/win32/browseui/internettoolbar.cpp +++ b/dll/win32/browseui/internettoolbar.cpp @@ -646,6 +646,9 @@ HRESULT STDMETHODCALLTYPE CMenuCallback::CallbackSM(LPSMDATA psmd, UINT uMsg, WP return GetObject(psmd, *reinterpret_cast(wParam), reinterpret_cast(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; diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index 63f32713eec..94920c76fee 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -22,6 +22,7 @@ #include #include +#include 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 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); @@ -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_FAVORITES_ORGANIZEFAVORITES, OnOrganizeFavorites) 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 = shellMenu->SetMenu(hmenuShared, NULL, SMSET_DONTOWN); + hResult = shellMenu->SetMenu(hmenuShared, m_hWnd, SMSET_DONTOWN); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; fCurrentMenuBar = hmenuShared; @@ -3252,9 +3255,54 @@ LRESULT CShellBrowser::OnBackspace(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO return 0; } +LRESULT CShellBrowser::OnOrganizeFavorites(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled) +{ + CComPtr 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) { - 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; } diff --git a/include/reactos/undocshell.h b/include/reactos/undocshell.h index 5b1e785b5ae..2dee7566c9c 100644 --- a/include/reactos/undocshell.h +++ b/include/reactos/undocshell.h @@ -532,6 +532,9 @@ BOOL WINAPI SHDesktopMessageLoop(HANDLE); /* Utility functions */ #include +#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, ...) {