1 /* 2 * Virtual MyDocuments Folder 3 * 4 * Copyright 2007 Johannes Anderwald 5 * Copyright 2009 Andrew Hill 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 */ 21 22 #ifndef _SHFLDR_MYDOCUMENTS_H_ 23 #define _SHFLDR_MYDOCUMENTS_H_ 24 25 class CMyDocsFolder : 26 public CComCoClass<CMyDocsFolder, &CLSID_MyDocuments>, 27 public CComObjectRootEx<CComMultiThreadModelNoCS>, 28 public IShellFolder2, 29 public IPersistFolder2, 30 public IItemNameLimits 31 { 32 private: 33 CComPtr<IShellFolder2> m_pisfInner; 34 LPITEMIDLIST m_pidlInner; 35 36 HRESULT EnsureFolder(); 37 38 public: 39 CMyDocsFolder(); 40 ~CMyDocsFolder(); 41 42 HRESULT WINAPI FinalConstruct(); 43 44 // IShellFolder 45 STDMETHOD(ParseDisplayName)(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes) override; 46 STDMETHOD(EnumObjects)(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override; 47 STDMETHOD(BindToObject)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override; 48 STDMETHOD(BindToStorage)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override; 49 STDMETHOD(CompareIDs)(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) override; 50 STDMETHOD(CreateViewObject)(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override; 51 STDMETHOD(GetAttributesOf)(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override; 52 STDMETHOD(GetUIObjectOf)(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) override; 53 STDMETHOD(GetDisplayNameOf)(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) override; 54 STDMETHOD(SetNameOf)(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override; 55 56 /* ShellFolder2 */ 57 STDMETHOD(GetDefaultSearchGUID)(GUID *pguid) override; 58 STDMETHOD(EnumSearches)(IEnumExtraSearch **ppenum) override; 59 STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) override; 60 STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pcsFlags) override; 61 STDMETHOD(GetDetailsEx)(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) override; 62 STDMETHOD(GetDetailsOf)(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) override; 63 STDMETHOD(MapColumnToSCID)(UINT column, SHCOLUMNID *pscid) override; 64 65 // IPersist 66 STDMETHOD(GetClassID)(CLSID *lpClassId) override; 67 68 // IPersistFolder 69 STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl) override; 70 71 // IPersistFolder2 72 STDMETHOD(GetCurFolder)(PIDLIST_ABSOLUTE * pidl) override; 73 74 /*** IItemNameLimits methods ***/ 75 76 STDMETHODIMP 77 GetMaxLength(LPCWSTR pszName, int *piMaxNameLen) override 78 { 79 return E_NOTIMPL; 80 } 81 82 STDMETHODIMP 83 GetValidCharacters(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars) override 84 { 85 if (ppwszValidChars) 86 { 87 *ppwszValidChars = NULL; 88 } 89 if (ppwszInvalidChars) 90 { 91 SHStrDupW(INVALID_FILETITLE_CHARACTERSW, ppwszInvalidChars); 92 } 93 return S_OK; 94 } 95 96 DECLARE_REGISTRY_RESOURCEID(IDR_MYDOCUMENTS) 97 DECLARE_NOT_AGGREGATABLE(CMyDocsFolder) 98 99 DECLARE_PROTECT_FINAL_CONSTRUCT() 100 101 BEGIN_COM_MAP(CMyDocsFolder) 102 COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2) 103 COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder) 104 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder) 105 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2) 106 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) 107 COM_INTERFACE_ENTRY_IID(IID_IItemNameLimits, IItemNameLimits) 108 END_COM_MAP() 109 }; 110 111 #endif /* _SHFLDR_MYDOCUMENTS_H_ */ 112