update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / Include / ShellPidl.h
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
4 // You may use this source code, compile or redistribute it as part of your application 
5 // for free. You cannot redistribute it as a part of a software development 
6 // library without the agreement of the author. If the sources are 
7 // distributed along with the application, you should leave the original 
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 // ShellPidl.h: interface for the CShellPidl class.
19 //
20 //////////////////////////////////////////////////////////////////////
21
22 #if !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)
23 #define AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_
24
25 #if _MSC_VER > 1000
26 #pragma once
27 #endif // _MSC_VER > 1000
28
29 #include "Refresh.h"
30
31 class CTRL_EXT_CLASS CShellPidl  
32 {
33 public:
34         CShellPidl();
35         virtual ~CShellPidl();
36 public:
37         virtual BOOL PopupTheMenu(HWND hwnd, LPSHELLFOLDER lpsfParent, LPITEMIDLIST  *lpi, UINT cidl, LPPOINT lppt);
38         virtual BOOL HandleMenuMsg(HWND hwnd, LPSHELLFOLDER lpsfParent,
39                                                                 LPITEMIDLIST  lpi, UINT uMsg, WPARAM wParam, LPARAM lParam);
40 #ifdef _UNICODE
41         STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
42 #else
43         STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
44 #endif
45         STDMETHOD(ResolveChannel)(IShellFolder* pFolder, LPCITEMIDLIST pidl, LPTSTR* lpszURL);
46         STDMETHOD(ResolveHistoryShortcut)(LPSHELLFOLDER pFolder,LPCITEMIDLIST *ppidl,CString &sURL);
47         STDMETHOD(ResolveInternetShortcut)(LPCTSTR lpszLinkFile, LPTSTR* lpszURL);
48         STDMETHOD(ResolveLink)(HWND hWnd,LPCTSTR lpszLinkFile, LPTSTR* lpszPath);
49         STDMETHOD(SHPathToPidlEx)(LPCTSTR szPath, LPITEMIDLIST* ppidl, LPSHELLFOLDER pFolder=NULL);
50         STDMETHOD(SHPidlToPathEx)(LPCITEMIDLIST pidl, CString &sPath, LPSHELLFOLDER pFolder=NULL,DWORD dwFlags=SHGDN_FORPARSING);
51         LPITEMIDLIST CopyItemIDList(LPITEMIDLIST pidl);
52         LPITEMIDLIST CopyItemID(LPITEMIDLIST pidl,int n=0);
53         LPITEMIDLIST CopyLastItemID(LPITEMIDLIST pidl);
54         LPITEMIDLIST CopyAbsItemID(LPITEMIDLIST pidl,int n);
55         LPITEMIDLIST ConcatPidl(LPITEMIDLIST pidlDest,LPITEMIDLIST pidlSrc);
56         LPITEMIDLIST Next(LPCITEMIDLIST pidl);
57         LPSHELLFOLDER GetFolder(LPITEMIDLIST pidl);
58         LPSHELLFOLDER GetDesktopFolder();
59         LPCITEMIDLIST GetEmptyPidl();
60         bool IsDesktopFolder(LPSHELLFOLDER psFolder);
61         DWORD GetDragDropAttributes(COleDataObject *pDataObject);
62         DWORD GetDragDropAttributes(LPTVITEMDATA ptvid);
63         DWORD GetDragDropAttributes(LPLVITEMDATA plvid);
64         DWORD GetDragDropAttributes(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl);
65         UINT GetSize(LPCITEMIDLIST pidl);
66         UINT GetCount(LPCITEMIDLIST pidl);
67         void GetTypeName(LPITEMIDLIST lpi,CString &sTypeName);
68         void GetDisplayName(LPITEMIDLIST lpi,CString &sDisplayName);
69         int GetIcon(LPITEMIDLIST lpi, UINT uFlags);
70         void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, int &iImage, int &iSelectedImage);
71         BOOL GetName (LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, CString &sFriendlyName);
72         bool ComparePidls(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2);
73         bool CompareMemPidls(LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2);
74         IMalloc *GetMalloc();
75         void FreePidl(LPITEMIDLIST pidl);
76         void Free(void *pv);
77 protected:
78         STDMETHOD(GetURL)(IDataObject *pDataObj,CString &sURL);
79 private:
80         ITEMIDLIST m_EmptyPidl;
81         LPMALLOC m_pMalloc;
82         LPSHELLFOLDER m_psfDesktop;
83 };
84
85 ////////////////////////////////////////////////
86 // CShellPidlCompare
87 ////////////////////////////////////////////////
88 class CShellPidlCompare
89 {
90 public:
91         CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl);
92         CShellPidlCompare(const CShellPidlCompare &rOther);
93         const CShellPidlCompare &operator=(const CShellPidlCompare &rOther);
94         bool operator==(const CShellPidlCompare &rhs) const;
95         bool operator<(const CShellPidlCompare &rhs) const;
96     virtual ~CShellPidlCompare();
97         LPCITEMIDLIST GetPidl() const;
98         LPSHELLFOLDER GetFolder() const;
99 public:
100 protected:
101 private:
102     LPITEMIDLIST m_pidl;
103         LPSHELLFOLDER m_pFolder;
104 };
105
106
107 inline CShellPidlCompare::CShellPidlCompare(const CShellPidlCompare &rOther)
108  :      m_pidl(rOther.m_pidl),
109         m_pFolder(rOther.m_pFolder)
110 {
111 }
112
113 inline bool CShellPidlCompare::operator==(const CShellPidlCompare &rhs) const
114 {
115         HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
116         return (short)hr == 0;
117 }
118
119 inline bool CShellPidlCompare::operator<(const CShellPidlCompare &rhs) const
120 {
121         HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
122         return (short)hr < 0;
123 }
124
125 inline const CShellPidlCompare &CShellPidlCompare::operator=(const CShellPidlCompare &rOther)
126 {
127         if (this == &rOther)
128                 return *this;
129
130         m_pidl = rOther.m_pidl;
131         m_pFolder = rOther.m_pFolder;
132
133         return *this;
134 }
135
136 inline CShellPidlCompare::CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl)
137 : m_pidl(pidl),
138         m_pFolder(pFolder)
139 {
140
141 }
142
143 inline CShellPidlCompare::~CShellPidlCompare()
144 {
145
146 }
147
148 inline LPCITEMIDLIST CShellPidlCompare::GetPidl() const
149 {
150         return m_pidl;
151 }
152
153 inline LPSHELLFOLDER CShellPidlCompare::GetFolder() const
154 {
155         return m_pFolder;
156 }
157
158 #endif // !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)