1 //*******************************************************************************
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.
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
18 // ShellPidl.h: interface for the CShellPidl class.
20 //////////////////////////////////////////////////////////////////////
22 #if !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)
23 #define AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_
27 #endif // _MSC_VER > 1000
31 class CTRL_EXT_CLASS CShellPidl
35 virtual ~CShellPidl();
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);
41 STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
43 STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
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);
75 void FreePidl(LPITEMIDLIST pidl);
78 STDMETHOD(GetURL)(IDataObject *pDataObj,CString &sURL);
80 ITEMIDLIST m_EmptyPidl;
82 LPSHELLFOLDER m_psfDesktop;
85 ////////////////////////////////////////////////
87 ////////////////////////////////////////////////
88 class CShellPidlCompare
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;
103 LPSHELLFOLDER m_pFolder;
107 inline CShellPidlCompare::CShellPidlCompare(const CShellPidlCompare &rOther)
108 : m_pidl(rOther.m_pidl),
109 m_pFolder(rOther.m_pFolder)
113 inline bool CShellPidlCompare::operator==(const CShellPidlCompare &rhs) const
115 HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
116 return (short)hr == 0;
119 inline bool CShellPidlCompare::operator<(const CShellPidlCompare &rhs) const
121 HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
122 return (short)hr < 0;
125 inline const CShellPidlCompare &CShellPidlCompare::operator=(const CShellPidlCompare &rOther)
130 m_pidl = rOther.m_pidl;
131 m_pFolder = rOther.m_pFolder;
136 inline CShellPidlCompare::CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl)
143 inline CShellPidlCompare::~CShellPidlCompare()
148 inline LPCITEMIDLIST CShellPidlCompare::GetPidl() const
153 inline LPSHELLFOLDER CShellPidlCompare::GetFolder() const
158 #endif // !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)