1 // Windows/Shell.h 2 3 #ifndef __WINDOWS_SHELL_H 4 #define __WINDOWS_SHELL_H 5 6 #include "../Common/MyWindows.h" 7 #include <ShlObj.h> 8 9 #include "../Common/MyString.h" 10 11 #include "Defs.h" 12 13 namespace NWindows{ 14 namespace NShell{ 15 16 ///////////////////////// 17 // CItemIDList 18 #ifndef UNDER_CE 19 20 class CItemIDList 21 { 22 LPITEMIDLIST m_Object; 23 public: CItemIDList()24 CItemIDList(): m_Object(NULL) {} 25 // CItemIDList(LPCITEMIDLIST itemIDList); 26 // CItemIDList(const CItemIDList& itemIDList); ~CItemIDList()27 ~CItemIDList() { Free(); } 28 void Free(); Attach(LPITEMIDLIST object)29 void Attach(LPITEMIDLIST object) 30 { 31 Free(); 32 m_Object = object; 33 } Detach()34 LPITEMIDLIST Detach() 35 { 36 LPITEMIDLIST object = m_Object; 37 m_Object = NULL; 38 return object; 39 } LPITEMIDLIST()40 operator LPITEMIDLIST() { return m_Object;} LPCITEMIDLIST()41 operator LPCITEMIDLIST() const { return m_Object;} 42 LPITEMIDLIST* operator&() { return &m_Object; } 43 LPITEMIDLIST operator->() { return m_Object; } 44 45 // CItemIDList& operator=(LPCITEMIDLIST object); 46 // CItemIDList& operator=(const CItemIDList &object); 47 }; 48 49 ///////////////////////////// 50 // CDrop 51 52 class CDrop 53 { 54 HDROP m_Object; 55 bool m_MustBeFinished; 56 bool m_Assigned; 57 void Free(); 58 public: CDrop(bool mustBeFinished)59 CDrop(bool mustBeFinished) : m_MustBeFinished(mustBeFinished), m_Assigned(false) {} ~CDrop()60 ~CDrop() { Free(); } 61 62 void Attach(HDROP object); HDROP()63 operator HDROP() { return m_Object;} QueryPoint(LPPOINT point)64 bool QueryPoint(LPPOINT point) 65 { return BOOLToBool(::DragQueryPoint(m_Object, point)); } Finish()66 void Finish() { ::DragFinish(m_Object); } QueryFile(UINT fileIndex,LPTSTR fileName,UINT fileNameSize)67 UINT QueryFile(UINT fileIndex, LPTSTR fileName, UINT fileNameSize) 68 { return ::DragQueryFile(m_Object, fileIndex, fileName, fileNameSize); } 69 #ifndef _UNICODE QueryFile(UINT fileIndex,LPWSTR fileName,UINT fileNameSize)70 UINT QueryFile(UINT fileIndex, LPWSTR fileName, UINT fileNameSize) 71 { return ::DragQueryFileW(m_Object, fileIndex, fileName, fileNameSize); } 72 #endif 73 UINT QueryCountOfFiles(); 74 UString QueryFileName(UINT fileIndex); 75 void QueryFileNames(UStringVector &fileNames); 76 }; 77 78 #endif 79 80 ///////////////////////////// 81 // Functions 82 83 bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path); 84 bool BrowseForFolder(LPBROWSEINFO lpbi, CSysString &resultPath); 85 bool BrowseForFolder(HWND owner, LPCTSTR title, LPCTSTR initialFolder, CSysString &resultPath); 86 87 #ifndef _UNICODE 88 bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path); 89 bool BrowseForFolder(LPBROWSEINFO lpbi, UString &resultPath); 90 bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath); 91 #endif 92 }} 93 94 #endif 95