ShellPidl.h
上传用户:yatsl7111
上传日期:2007-01-08
资源大小:1433k
文件大小:5k
源码类别:

图形图象

开发平台:

Visual C++

  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. // ShellPidl.h: interface for the CShellPidl class.
  18. //
  19. //////////////////////////////////////////////////////////////////////
  20. #if !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)
  21. #define AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_
  22. #if _MSC_VER > 1000
  23. #pragma once
  24. #endif // _MSC_VER > 1000
  25. #include "Refresh.h"
  26. class CTRL_EXT_CLASS CShellPidl  
  27. {
  28. public:
  29. CShellPidl();
  30. virtual ~CShellPidl();
  31. public:
  32. virtual BOOL PopupTheMenu(HWND hwnd, LPSHELLFOLDER lpsfParent, LPITEMIDLIST  *lpi, UINT cidl, LPPOINT lppt);
  33. virtual BOOL HandleMenuMsg(HWND hwnd, LPSHELLFOLDER lpsfParent,
  34. LPITEMIDLIST  lpi, UINT uMsg, WPARAM wParam, LPARAM lParam);
  35. #ifdef _UNICODE
  36. STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
  37. #else
  38. STDMETHOD(StrRetToStr)(STRRET StrRet, LPTSTR* str, LPITEMIDLIST pidl);
  39. #endif
  40. STDMETHOD(ResolveChannel)(IShellFolder* pFolder, LPCITEMIDLIST pidl, LPTSTR* lpszURL);
  41. STDMETHOD(ResolveHistoryShortcut)(LPSHELLFOLDER pFolder,LPCITEMIDLIST *ppidl,CString &sURL);
  42. STDMETHOD(ResolveInternetShortcut)(LPCTSTR lpszLinkFile, LPTSTR* lpszURL);
  43. STDMETHOD(ResolveLink)(HWND hWnd,LPCTSTR lpszLinkFile, LPTSTR* lpszPath);
  44. STDMETHOD(SHPathToPidlEx)(LPCTSTR szPath, LPITEMIDLIST* ppidl, LPSHELLFOLDER pFolder=NULL);
  45. STDMETHOD(SHPidlToPathEx)(LPCITEMIDLIST pidl, CString &sPath, LPSHELLFOLDER pFolder=NULL,DWORD dwFlags=SHGDN_FORPARSING);
  46. LPITEMIDLIST CopyItemIDList(LPITEMIDLIST pidl);
  47. LPITEMIDLIST CopyItemID(LPITEMIDLIST pidl,int n=0);
  48. LPITEMIDLIST CopyLastItemID(LPITEMIDLIST pidl);
  49. LPITEMIDLIST CopyAbsItemID(LPITEMIDLIST pidl,int n);
  50. LPITEMIDLIST ConcatPidl(LPITEMIDLIST pidlDest,LPITEMIDLIST pidlSrc);
  51. LPITEMIDLIST Next(LPCITEMIDLIST pidl);
  52. LPSHELLFOLDER GetFolder(LPITEMIDLIST pidl);
  53. LPSHELLFOLDER GetDesktopFolder();
  54. LPCITEMIDLIST GetEmptyPidl();
  55. bool IsDesktopFolder(LPSHELLFOLDER psFolder);
  56. DWORD GetDragDropAttributes(COleDataObject *pDataObject);
  57. DWORD GetDragDropAttributes(LPTVITEMDATA ptvid);
  58. DWORD GetDragDropAttributes(LPLVITEMDATA plvid);
  59. DWORD GetDragDropAttributes(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl);
  60. UINT GetSize(LPCITEMIDLIST pidl);
  61. UINT GetCount(LPCITEMIDLIST pidl);
  62. void GetTypeName(LPITEMIDLIST lpi,CString &sTypeName);
  63. void GetDisplayName(LPITEMIDLIST lpi,CString &sDisplayName);
  64. int GetIcon(LPITEMIDLIST lpi, UINT uFlags);
  65. void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, int &iImage, int &iSelectedImage);
  66. BOOL GetName (LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, CString &sFriendlyName);
  67. bool ComparePidls(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2);
  68. bool CompareMemPidls(LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2);
  69. IMalloc *GetMalloc();
  70. void FreePidl(LPITEMIDLIST pidl);
  71. void Free(void *pv);
  72. protected:
  73. STDMETHOD(GetURL)(IDataObject *pDataObj,CString &sURL);
  74. private:
  75. ITEMIDLIST m_EmptyPidl;
  76. LPMALLOC m_pMalloc;
  77. LPSHELLFOLDER m_psfDesktop;
  78. };
  79. ////////////////////////////////////////////////
  80. // CShellPidlCompare
  81. ////////////////////////////////////////////////
  82. class CShellPidlCompare
  83. {
  84. public:
  85. CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl);
  86. CShellPidlCompare(const CShellPidlCompare &rOther);
  87. const CShellPidlCompare &operator=(const CShellPidlCompare &rOther);
  88. bool operator==(const CShellPidlCompare &rhs) const;
  89. bool operator<(const CShellPidlCompare &rhs) const;
  90.     virtual ~CShellPidlCompare();
  91. LPCITEMIDLIST GetPidl() const;
  92. LPSHELLFOLDER GetFolder() const;
  93. public:
  94. protected:
  95. private:
  96.     LPITEMIDLIST m_pidl;
  97. LPSHELLFOLDER m_pFolder;
  98. };
  99. inline CShellPidlCompare::CShellPidlCompare(const CShellPidlCompare &rOther)
  100.  :  m_pidl(rOther.m_pidl),
  101. m_pFolder(rOther.m_pFolder)
  102. {
  103. }
  104. inline bool CShellPidlCompare::operator==(const CShellPidlCompare &rhs) const
  105. {
  106. HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
  107. return (short)hr == 0;
  108. }
  109. inline bool CShellPidlCompare::operator<(const CShellPidlCompare &rhs) const
  110. {
  111. HRESULT hr = m_pFolder->CompareIDs(0,m_pidl,rhs.m_pidl);
  112. return (short)hr < 0;
  113. }
  114. inline const CShellPidlCompare &CShellPidlCompare::operator=(const CShellPidlCompare &rOther)
  115. {
  116. if (this == &rOther)
  117. return *this;
  118. m_pidl = rOther.m_pidl;
  119. m_pFolder = rOther.m_pFolder;
  120. return *this;
  121. }
  122. inline CShellPidlCompare::CShellPidlCompare(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl)
  123. : m_pidl(pidl),
  124. m_pFolder(pFolder)
  125. {
  126. }
  127. inline CShellPidlCompare::~CShellPidlCompare()
  128. {
  129. }
  130. inline LPCITEMIDLIST CShellPidlCompare::GetPidl() const
  131. {
  132. return m_pidl;
  133. }
  134. inline LPSHELLFOLDER CShellPidlCompare::GetFolder() const
  135. {
  136. return m_pFolder;
  137. }
  138. #endif // !defined(AFX_SHELLPIDL_H__D704F47E_1D35_4C7C_9F90_B3071B25DCB2__INCLUDED_)