1 // Windows/Shell.h 2 3 #ifndef ZIP7_WINDOWS_SHELL_H 4 #define ZIP7_WINDOWS_SHELL_H 5 6 #include "../Common/MyWindows.h" 7 #if defined(__MINGW32__) || defined(__MINGW64__) 8 #include <shlobj.h> 9 #else 10 #include <ShlObj.h> 11 #endif 12 13 #include "../Common/MyString.h" 14 15 #include "Defs.h" 16 17 namespace NWindows { 18 namespace NShell { 19 20 ///////////////////////// 21 // CItemIDList 22 #ifndef UNDER_CE 23 24 class CItemIDList 25 { 26 LPITEMIDLIST m_Object; Z7_CLASS_NO_COPY(CItemIDList)27 Z7_CLASS_NO_COPY(CItemIDList) 28 public: 29 CItemIDList(): m_Object(NULL) {} 30 // CItemIDList(LPCITEMIDLIST itemIDList); 31 // CItemIDList(const CItemIDList& itemIDList); ~CItemIDList()32 ~CItemIDList() { Free(); } 33 void Free(); Attach(LPITEMIDLIST object)34 void Attach(LPITEMIDLIST object) 35 { 36 Free(); 37 m_Object = object; 38 } Detach()39 LPITEMIDLIST Detach() 40 { 41 LPITEMIDLIST object = m_Object; 42 m_Object = NULL; 43 return object; 44 } LPITEMIDLIST()45 operator LPITEMIDLIST() { return m_Object;} LPCITEMIDLIST()46 operator LPCITEMIDLIST() const { return m_Object;} 47 LPITEMIDLIST* operator&() { return &m_Object; } 48 LPITEMIDLIST operator->() { return m_Object; } 49 50 // CItemIDList& operator=(LPCITEMIDLIST object); 51 // CItemIDList& operator=(const CItemIDList &object); 52 }; 53 54 ///////////////////////////// 55 // CDrop 56 57 /* 58 class CDrop 59 { 60 HDROP m_Object; 61 bool m_MustBeFinished; 62 bool m_Assigned; 63 void Free(); 64 public: 65 CDrop(bool mustBeFinished) : m_MustBeFinished(mustBeFinished), m_Assigned(false) {} 66 ~CDrop() { Free(); } 67 68 void Attach(HDROP object); 69 operator HDROP() { return m_Object;} 70 bool QueryPoint(LPPOINT point) 71 { return BOOLToBool(::DragQueryPoint(m_Object, point)); } 72 void Finish() 73 { 74 ::DragFinish(m_Object); 75 } 76 UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT bufSize) 77 { return ::DragQueryFile(m_Object, fileIndex, fileName, bufSize); } 78 #ifndef _UNICODE 79 UINT QueryFile(UINT fileIndex, LPWSTR fileName, UINT bufSize) 80 { return ::DragQueryFileW(m_Object, fileIndex, fileName, bufSize); } 81 #endif 82 UINT QueryCountOfFiles(); 83 void QueryFileName(UINT fileIndex, UString &fileName); 84 void QueryFileNames(UStringVector &fileNames); 85 }; 86 */ 87 #endif 88 89 struct CFileAttribs 90 { 91 int FirstDirIndex; 92 // DWORD Sum; 93 // DWORD Product; 94 // CRecordVector<DWORD> Vals; 95 // CRecordVector<bool> IsDirVector; 96 CFileAttribsCFileAttribs97 CFileAttribs() 98 { 99 Clear(); 100 } 101 ClearCFileAttribs102 void Clear() 103 { 104 FirstDirIndex = -1; 105 // Sum = 0; 106 // Product = 0; 107 // IsDirVector.Clear(); 108 } 109 }; 110 111 112 /* read pathnames from HDROP or SHELLIDLIST. 113 The parser can return E_INVALIDARG, if there is some unexpected data in dataObject */ 114 HRESULT DataObject_GetData_HDROP_or_IDLIST_Names(IDataObject *dataObject, UStringVector &names); 115 116 HRESULT DataObject_GetData_FILE_ATTRS(IDataObject *dataObject, CFileAttribs &attribs); 117 118 bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path); 119 bool BrowseForFolder(LPBROWSEINFO lpbi, CSysString &resultPath); 120 bool BrowseForFolder(HWND owner, LPCTSTR title, LPCTSTR initialFolder, CSysString &resultPath); 121 122 #ifndef _UNICODE 123 bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path); 124 bool BrowseForFolder(LPBROWSEINFO lpbi, UString &resultPath); 125 bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath); 126 #endif 127 }} 128 129 #endif 130