Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
4.9 KiB

  1. /**************************************************************************
  2. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright 1998 Microsoft Corporation. All Rights Reserved.
  7. **************************************************************************/
  8. /**************************************************************************
  9. File: ExtrIcon.cpp
  10. Description: Implements CExtractIcon.
  11. **************************************************************************/
  12. /**************************************************************************
  13. #include statements
  14. **************************************************************************/
  15. #include "ExtrIcon.h"
  16. /**************************************************************************
  17. CExtractIcon::CExtractIcon()
  18. **************************************************************************/
  19. CExtractIcon::CExtractIcon(LPCITEMIDLIST pidl)
  20. {
  21. g_DllRefCount++;
  22. m_pPidlMgr = new CPidlMgr();
  23. if(!m_pPidlMgr)
  24. {
  25. delete this;
  26. return;
  27. }
  28. m_pidl = m_pPidlMgr->Copy(pidl);
  29. m_ObjRefCount = 1;
  30. }
  31. /**************************************************************************
  32. CExtractIcon::~CExtractIcon()
  33. **************************************************************************/
  34. CExtractIcon::~CExtractIcon()
  35. {
  36. if(m_pidl)
  37. {
  38. m_pPidlMgr->Delete(m_pidl);
  39. m_pidl = NULL;
  40. }
  41. if(m_pPidlMgr)
  42. {
  43. delete m_pPidlMgr;
  44. }
  45. g_DllRefCount--;
  46. }
  47. ///////////////////////////////////////////////////////////////////////////
  48. //
  49. // IUnknown Implementation
  50. //
  51. /**************************************************************************
  52. CExtractIcon::QueryInterface
  53. **************************************************************************/
  54. STDMETHODIMP CExtractIcon::QueryInterface(REFIID riid, LPVOID *ppReturn)
  55. {
  56. *ppReturn = NULL;
  57. //IUnknown
  58. if(IsEqualIID(riid, IID_IUnknown))
  59. {
  60. *ppReturn = this;
  61. }
  62. //IExtractIcon
  63. else if(IsEqualIID(riid, IID_IExtractIcon))
  64. {
  65. *ppReturn = (IExtractIcon*)this;
  66. }
  67. if(*ppReturn)
  68. {
  69. (*(LPUNKNOWN*)ppReturn)->AddRef();
  70. return S_OK;
  71. }
  72. return E_NOINTERFACE;
  73. }
  74. /**************************************************************************
  75. CExtractIcon::AddRef
  76. **************************************************************************/
  77. STDMETHODIMP_(DWORD) CExtractIcon::AddRef()
  78. {
  79. return ++m_ObjRefCount;
  80. }
  81. /**************************************************************************
  82. CExtractIcon::Release
  83. **************************************************************************/
  84. STDMETHODIMP_(DWORD) CExtractIcon::Release()
  85. {
  86. if(--m_ObjRefCount == 0)
  87. {
  88. delete this;
  89. return 0;
  90. }
  91. return m_ObjRefCount;
  92. }
  93. ///////////////////////////////////////////////////////////////////////////
  94. //
  95. // IExtractIcon Implementation
  96. //
  97. /**************************************************************************
  98. CExtractIcon::GetIconLocation()
  99. **************************************************************************/
  100. STDMETHODIMP CExtractIcon::GetIconLocation( UINT uFlags,
  101. LPTSTR szIconFile,
  102. UINT cchMax,
  103. LPINT piIndex,
  104. LPUINT puFlags)
  105. {
  106. //tell the shell to always call Extract
  107. *puFlags = GIL_NOTFILENAME;
  108. //the pidl is either a value or a folder, so find out which it is
  109. if(m_pPidlMgr->IsFolder(m_pPidlMgr->GetLastItem(m_pidl)))
  110. {
  111. //its a folder
  112. if(uFlags & GIL_OPENICON)
  113. {
  114. //tell Extract to return the open folder icon
  115. *piIndex = ICON_INDEX_FOLDEROPEN;
  116. }
  117. else
  118. {
  119. //tell Extract to return the closed folder icon
  120. *piIndex = ICON_INDEX_FOLDER;
  121. }
  122. }
  123. else
  124. {
  125. //its not a folder
  126. *piIndex = m_pPidlMgr->GetIcon(m_pPidlMgr->GetLastItem(m_pidl));
  127. if (*piIndex < 0)
  128. *piIndex = ICON_INDEX_ITEM; //tell Extract to return the item icon
  129. }
  130. return S_OK;
  131. }
  132. /**************************************************************************
  133. CExtractIcon::Extract()
  134. **************************************************************************/
  135. STDMETHODIMP CExtractIcon::Extract( LPCTSTR pszFile,
  136. UINT nIconIndex,
  137. HICON *phiconLarge,
  138. HICON *phiconSmall,
  139. UINT nIconSize)
  140. {
  141. *phiconLarge = ImageList_GetIcon(g_himlLarge, nIconIndex, ILD_TRANSPARENT);
  142. *phiconSmall = ImageList_GetIcon(g_himlSmall, nIconIndex, ILD_TRANSPARENT);
  143. return S_OK;
  144. }