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