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.

229 lines
6.0 KiB

  1. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  2. //
  3. // view.cpp
  4. //
  5. // IShellView helper functions. Cdf view uses the default IShellView and
  6. // relies on a callback to supply specific information.
  7. //
  8. // History:
  9. //
  10. // 3/20/97 edwardp Created.
  11. //
  12. ////////////////////////////////////////////////////////////////////////////////
  13. //
  14. // Includes
  15. //
  16. #include "stdinc.h"
  17. #include "view.h"
  18. #include "cdfidl.h"
  19. #include "resource.h"
  20. #include <mluisupp.h>
  21. #include <shellp.h> // SHCreateShellFolderViewEx
  22. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  23. //
  24. // *** CreateDefaultShellView ***
  25. //
  26. //
  27. // Description:
  28. // Creates a shell implemented default IShellView object for the given
  29. // folder.
  30. //
  31. // Parameters:
  32. // [In] pIShellFolder - The folder for which the default IShellView is
  33. // created.
  34. // [In] pidl - The id list for the given folder.
  35. // [Out] ppIShellView - A pointer to receive the IShellView interface.
  36. //
  37. // Return:
  38. // The result from the private shell function SHCreateShellFolderViewEx.
  39. //
  40. // Comments:
  41. // The default IShellView object communicates with its associated folder
  42. // via a callback function.
  43. //
  44. ////////////////////////////////////////////////////////////////////////////////
  45. HRESULT
  46. CreateDefaultShellView(
  47. IShellFolder *pIShellFolder,
  48. LPITEMIDLIST pidl,
  49. IShellView** ppIShellView
  50. )
  51. {
  52. ASSERT(pIShellFolder);
  53. ASSERT(ppIShellView);
  54. CSFV csfv;
  55. csfv.cbSize = sizeof(CSFV);
  56. csfv.pshf = pIShellFolder;
  57. csfv.psvOuter = NULL;
  58. csfv.pidl = pidl;
  59. csfv.lEvents = 0; //SHCNE_DELETE | SHCNE_CREATE;
  60. csfv.pfnCallback = IShellViewCallback;
  61. csfv.fvm = (FOLDERVIEWMODE)0; // FVM_ICON, FVM_DETAILS, etc.
  62. return SHCreateShellFolderViewEx(&csfv, ppIShellView);
  63. }
  64. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  65. //
  66. // *** IShellViewCallback ***
  67. //
  68. //
  69. // Description:
  70. // The callback function used by the default ISHellView to request
  71. // inforamtion.
  72. //
  73. // Parameters:
  74. // [In] pIShellViewOuter - Always NULL.
  75. // [In] pIShellFolder - The folder associated with this view.
  76. // [In] hwnd - The hwnd of the shell view.
  77. // [In] msg - The callback message.
  78. // [InOut] wParam - Message specific parameter.
  79. // [InOut] lParam - Message specific parameter.
  80. //
  81. // Return:
  82. //
  83. //
  84. // Comments:
  85. //
  86. //
  87. ////////////////////////////////////////////////////////////////////////////////
  88. HRESULT
  89. CALLBACK IShellViewCallback(
  90. IShellView* pIShellViewOuter,
  91. IShellFolder* pIShellFolder,
  92. HWND hwnd,
  93. UINT msg,
  94. WPARAM wParam,
  95. LPARAM lParam
  96. )
  97. {
  98. HRESULT hr;
  99. switch (msg)
  100. {
  101. case DVM_GETDETAILSOF:
  102. hr = IShellView_GetDetails((UINT)wParam, (PDETAILSINFO)lParam);
  103. break;
  104. //
  105. // Background enumeration only works for default shell view.
  106. //
  107. //case SFVM_BACKGROUNDENUM:
  108. // hr = S_OK;
  109. // TraceMsg(TF_CDFENUM, "Enum Background thread callback tid:0x%x",
  110. // GetCurrentThreadId());
  111. // break;
  112. default:
  113. hr = E_FAIL;
  114. break;
  115. }
  116. return hr;
  117. }
  118. //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
  119. //
  120. // *** IShellView_GetDetails ***
  121. //
  122. //
  123. // Description:
  124. // The IShellView callback DVM_GETDETAILSOF message handler.
  125. //
  126. // Parameters:
  127. // [In] nColumn - The column for wich information is requested.
  128. // [InOut] pDetails - For column headings the pidl param is NULL and the
  129. // columns format, width, and title are returned. For
  130. // items the pidl member conatins the id list of the
  131. // requested item and the string value of the requested
  132. // item is returned.
  133. //
  134. // Return:
  135. // S_OK if nColumn is supported.
  136. // E_FAIL if nColumn is greater than the number of supported columns.
  137. //
  138. // Comments:
  139. // The default shell view calls this function with successively higher
  140. // column numbers until an E_FAIL is returned.
  141. //
  142. // The first (0) column is the display name.
  143. //
  144. ////////////////////////////////////////////////////////////////////////////////
  145. HRESULT
  146. IShellView_GetDetails(
  147. UINT nColumn,
  148. PDETAILSINFO pDetails
  149. )
  150. {
  151. //
  152. // Column information.
  153. //
  154. #define COLUMNS (sizeof(aColumnInfo) / sizeof(aColumnInfo[0]))
  155. static const struct _tagCOLUMNINFO
  156. {
  157. UINT idsName;
  158. UINT cchWidth;
  159. USHORT uFormat;
  160. }
  161. aColumnInfo[] = {
  162. {IDS_COLUMN_NAME, 50, LVCFMT_LEFT}
  163. };
  164. HRESULT hr;
  165. if (nColumn < COLUMNS)
  166. {
  167. if (NULL != pDetails->pidl) {
  168. //
  169. // Get item information from the pidl.
  170. //
  171. switch (aColumnInfo[nColumn].idsName)
  172. {
  173. case IDS_COLUMN_NAME:
  174. //pDetails->str.uType = STRRET_CSTR;
  175. CDFIDL_GetDisplayName((PCDFITEMIDLIST)pDetails->pidl,
  176. &pDetails->str);
  177. break;
  178. }
  179. }
  180. else
  181. {
  182. //
  183. // Get column heading information.
  184. //
  185. pDetails->fmt = aColumnInfo[nColumn].uFormat;
  186. pDetails->cxChar = aColumnInfo[nColumn].cchWidth;
  187. pDetails->str.uType = STRRET_CSTR;
  188. //
  189. // REVIEW: Using MLLoadStringA.
  190. //
  191. MLLoadStringA(aColumnInfo[nColumn].idsName,
  192. pDetails->str.cStr, sizeof(pDetails->str.cStr));
  193. }
  194. hr = S_OK;
  195. }
  196. else
  197. {
  198. hr = E_FAIL;
  199. }
  200. return hr;
  201. }