[BROWSEUI][SHELL32] Stub Folder Options Property Page extension CORE-10837
authorMark Jansen <mark.jansen@reactos.org>
Sat, 23 Apr 2016 23:05:07 +0000 (23:05 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Sat, 23 Apr 2016 23:05:07 +0000 (23:05 +0000)
- Stub the Property pages
- Disable some code that prevented the property pages from working (CORE-11140)
- Leave the menu item disabled for now, since a dialog that does not do anything will only confuse people (CORE-11141)

svn path=/trunk/; revision=71192

reactos/dll/win32/browseui/shellbrowser.cpp
reactos/dll/win32/shell32/CFolderOptions.cpp [new file with mode: 0644]
reactos/dll/win32/shell32/CFolderOptions.h [new file with mode: 0644]
reactos/dll/win32/shell32/CMakeLists.txt
reactos/dll/win32/shell32/dialogs/folder_options.cpp
reactos/dll/win32/shell32/precomp.h
reactos/dll/win32/shell32/res/rgs/folderoptions.rgs
reactos/dll/win32/shell32/shell32.cpp

index 49a3e31..fb55bd1 100644 (file)
@@ -1254,6 +1254,9 @@ HRESULT CShellBrowser::DoFolderOptions()
     if (FAILED_UNEXPECTEDLY(hResult))
         return E_FAIL;
 
+// CORE-11140 : Disabled this bit, because it prevents the folder options from showing.
+//              It returns 'E_NOTIMPL'
+#if 0
     if (fCurrentShellView != NULL)
     {
         hResult = fCurrentShellView->AddPropertySheetPages(
@@ -1261,6 +1264,7 @@ HRESULT CShellBrowser::DoFolderOptions()
         if (FAILED_UNEXPECTEDLY(hResult))
             return E_FAIL;
     }
+#endif
 
     // show sheet
     m_PropSheet.dwSize = sizeof(PROPSHEETHEADER);
@@ -3203,7 +3207,7 @@ LRESULT CShellBrowser::OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam,
         SHEnableMenuItem(theMenu, IDM_TOOLS_MAPNETWORKDRIVE, FALSE);
         SHEnableMenuItem(theMenu, IDM_TOOLS_DISCONNECTNETWORKDRIVE, FALSE);
         SHEnableMenuItem(theMenu, IDM_TOOLS_SYNCHRONIZE, FALSE);
-        SHEnableMenuItem(theMenu, IDM_TOOLS_FOLDEROPTIONS, FALSE);
+        SHEnableMenuItem(theMenu, IDM_TOOLS_FOLDEROPTIONS, FALSE);  // Remove when CORE-11141 is fixed.
         menuIndex = 4;
     }
     else if (theMenu == SHGetMenuFromID(fCurrentMenuBar, FCIDM_MENU_HELP))
diff --git a/reactos/dll/win32/shell32/CFolderOptions.cpp b/reactos/dll/win32/shell32/CFolderOptions.cpp
new file mode 100644 (file)
index 0000000..3abb255
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Folder options.
+ *
+ * Copyright (C) 2016 Mark Jansen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <precomp.h>
+
+
+WINE_DEFAULT_DEBUG_CHANNEL(fprop);
+
+CFolderOptions::CFolderOptions()
+    :m_pSite(NULL)
+{
+}
+
+CFolderOptions::~CFolderOptions()
+{
+}
+
+/*************************************************************************
+ * FolderOptions IShellPropSheetExt interface
+ */
+
+INT_PTR CALLBACK FolderOptionsGeneralDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK FolderOptionsViewDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK FolderOptionsFileTypesDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+HRESULT STDMETHODCALLTYPE CFolderOptions::AddPages(LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
+{
+    HPROPSHEETPAGE hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_GENERAL, FolderOptionsGeneralDlg, 0, NULL);
+
+    if (hPage == NULL)
+    {
+        ERR("Failed to create property sheet page FolderOptionsGeneral\n");
+        return E_FAIL;
+    }
+    if (!pfnAddPage(hPage, lParam))
+        return E_FAIL;
+
+    hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_VIEW, FolderOptionsViewDlg, 0, NULL);
+    if (hPage == NULL)
+    {
+        ERR("Failed to create property sheet page FolderOptionsView\n");
+        return E_FAIL;
+    }
+    if (!pfnAddPage(hPage, lParam))
+        return E_FAIL;
+
+    hPage = SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_FILETYPES, FolderOptionsFileTypesDlg, 0, NULL);
+    if (hPage == NULL)
+    {
+        ERR("Failed to create property sheet page FolderOptionsFileTypes\n");
+        return E_FAIL;
+    }
+    if (!pfnAddPage(hPage, lParam))
+        return E_FAIL;
+
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE CFolderOptions::ReplacePage(EXPPS uPageID, LPFNSVADDPROPSHEETPAGE pfnReplaceWith, LPARAM lParam)
+{
+    TRACE("(%p) (uPageID %u, pfnReplaceWith %p lParam %p\n", this, uPageID, pfnReplaceWith, lParam);
+    return E_NOTIMPL;
+}
+
+/*************************************************************************
+ * FolderOptions IShellExtInit interface
+ */
+
+HRESULT STDMETHODCALLTYPE CFolderOptions::Initialize(LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
+{
+    return S_OK;
+}
+
+
+/*************************************************************************
+ * FolderOptions IShellExtInit interface
+ */
+HRESULT STDMETHODCALLTYPE CFolderOptions::SetSite(IUnknown *pUnkSite)
+{
+    m_pSite = pUnkSite;
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE CFolderOptions::GetSite(REFIID riid, void **ppvSite)
+{
+    return m_pSite->QueryInterface(riid, ppvSite);
+}
+
diff --git a/reactos/dll/win32/shell32/CFolderOptions.h b/reactos/dll/win32/shell32/CFolderOptions.h
new file mode 100644 (file)
index 0000000..37e4b5e
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Folder options.
+ *
+ * Copyright (C) 2016 Mark Jansen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef _CFOLDEROPTIONS_H_
+#define _CFOLDEROPTIONS_H_
+
+class CFolderOptions :
+    public CComCoClass<CFolderOptions, &CLSID_ShellFldSetExt>,
+    public CComObjectRootEx<CComMultiThreadModelNoCS>,
+    public IShellPropSheetExt,
+    public IShellExtInit,
+    public IObjectWithSite
+{
+    private:
+        CComPtr<IUnknown> m_pSite;
+        //LPITEMIDLIST pidl;
+        //INT iIdEmpty;
+        //UINT cfShellIDList;
+        //void SF_RegisterClipFmt();
+        //BOOL fAcceptFmt;       /* flag for pending Drop */
+        //BOOL QueryDrop (DWORD dwKeyState, LPDWORD pdwEffect);
+        //BOOL RecycleBinIsEmpty();
+
+    public:
+        CFolderOptions();
+        ~CFolderOptions();
+
+        // IShellPropSheetExt
+        virtual HRESULT STDMETHODCALLTYPE AddPages(LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam);
+        virtual HRESULT STDMETHODCALLTYPE ReplacePage(EXPPS uPageID, LPFNSVADDPROPSHEETPAGE pfnReplaceWith, LPARAM lParam);
+        
+        // IShellExtInit
+        virtual HRESULT STDMETHODCALLTYPE Initialize(LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID);
+
+        // IObjectWithSite
+        virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite);
+        virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite);
+
+        DECLARE_REGISTRY_RESOURCEID(IDR_FOLDEROPTIONS)
+        DECLARE_NOT_AGGREGATABLE(CFolderOptions)
+
+        DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+        BEGIN_COM_MAP(CFolderOptions)
+        COM_INTERFACE_ENTRY_IID(IID_IShellPropSheetExt, IShellPropSheetExt)
+        COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
+        COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
+        END_COM_MAP()
+};
+
+#endif /* _CFOLDEROPTIONS_H_ */
index 77e6d11..32a87e1 100644 (file)
@@ -42,6 +42,7 @@ list(APPEND SOURCE
     shell32.cpp
     CShellItem.cpp
     CShellLink.cpp
+    CFolderOptions.cpp
     folders/CDesktopFolder.cpp
     folders/CFSFolder.cpp
     folders/CDrivesFolder.cpp
index 6c486dc..bbbc35e 100644 (file)
@@ -83,7 +83,6 @@ static FOLDER_VIEW_ENTRY s_Options[] =
 
 EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
 
-static
 INT_PTR
 CALLBACK
 FolderOptionsGeneralDlg(
@@ -124,7 +123,6 @@ InitializeFolderOptionsListCtrl(HWND hwndDlg)
 
 }
 
-static
 INT_PTR
 CALLBACK
 FolderOptionsViewDlg(
@@ -384,7 +382,6 @@ FindSelectedItem(
     return NULL;
 }
 
-static
 INT_PTR
 CALLBACK
 FolderOptionsFileTypesDlg(
index 89c223c..f5a950d 100644 (file)
@@ -55,6 +55,7 @@
 #include "CFolder.h"
 #include "CShell.h"
 #include "CDropTargetHelper.h"
+#include "CFolderOptions.h"
 #include "folders/CFSFolder.h"
 #include "folders/CDrivesFolder.h"
 #include "folders/CDesktopFolder.h"
index eead3b6..4e43960 100644 (file)
@@ -27,6 +27,13 @@ HKCR
                                val Attributes = d '0'
                        }
                }
+               ForceRemove {6D5313C0-8C62-11D1-B2CD-006097DF8C11} = s 'Folder Options Property Page Extension'
+               {
+                       InprocServer32 = s '%MODULE%'
+                       {
+                               val ThreadingModel = s 'Apartment'
+                       }
+               }
        }
 }
 HKLM
index 38d6e2f..f68072a 100644 (file)
@@ -204,6 +204,7 @@ BEGIN_OBJECT_MAP(ObjectMap)
     OBJECT_ENTRY(CLSID_FontsFolderShortcut, CFontsFolder)
     OBJECT_ENTRY(CLSID_Printers, CPrinterFolder)
     OBJECT_ENTRY(CLSID_AdminFolderShortcut, CAdminToolsFolder)
+    OBJECT_ENTRY(CLSID_ShellFldSetExt, CFolderOptions)
     OBJECT_ENTRY(CLSID_RecycleBin, CRecycleBin)
     OBJECT_ENTRY(CLSID_OpenWithMenu, COpenWithMenu)
     OBJECT_ENTRY(CLSID_NewMenu, CNewMenu)