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