Source code of Windows XP (NT5)
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.

1008 lines
33 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I S H E L L V . C P P
  7. //
  8. // Contents: IShellView implementation for CConnectionFolder
  9. //
  10. // Notes: The IShellView interface is implemented to present a view
  11. // in the Windows Explorer or folder windows. The object that
  12. // exposes IShellView is created by a call to the
  13. // IShellFolder::CreateViewObject method. This provides the
  14. // channel of communication between a view object and the
  15. // Explorer's outermost frame window. The communication
  16. // involves the translation of messages, the state of the frame
  17. // window (activated or deactivated), and the state of the
  18. // document window (Activated or deactivated), and the merging
  19. // of menus and toolbar items. This object is created by the
  20. // IShellFolder object that hosts the view.
  21. //
  22. // Author: jeffspr 22 Sep 1997
  23. //
  24. //----------------------------------------------------------------------------
  25. #include "pch.h"
  26. #pragma hdrstop
  27. #include "foldinc.h" // Standard shell\folder includes
  28. #include "foldres.h" // Folder resource IDs
  29. #include "nsres.h" // Netshell strings
  30. #include "oncommand.h" // Command handlers
  31. #include "cmdtable.h" // Table of command properties
  32. #include <ras.h> // for RAS_MaxEntryName
  33. #include "webview.h"
  34. //---[ Compile flags ]--------------------------------------------------------
  35. #define NEW_CONNECTION_IN_TOOLBAR 0
  36. #define ANY_FREEKIN_THING_IN_TOOLBAR 0 // have any toolbar buttons?
  37. //---[ Constants ]------------------------------------------------------------
  38. #if ANY_FREEKIN_THING_IN_TOOLBAR
  39. const TBBUTTON c_tbConnections[] = {
  40. #if NEW_CONNECTION_IN_TOOLBAR
  41. { 0, CMIDM_NEW_CONNECTION, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0L, IDS_TOOLBAR_MAKE_NEW_STRING },
  42. #endif
  43. { 1, CMIDM_CONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0L, IDS_TOOLBAR_CONNECT_STRING },
  44. { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP , {0,0}, 0L, -1 },
  45. };
  46. const DWORD c_nToolbarButtons = celems(c_tbConnections);
  47. #else
  48. const DWORD c_nToolbarButtons = 0;
  49. #endif
  50. //---[ Prototypes ]-----------------------------------------------------------
  51. HRESULT HrOnFolderRefresh(
  52. HWND hwndOwner,
  53. LPARAM lParam,
  54. WPARAM wParam);
  55. HRESULT HrOnFolderGetButtonInfo(
  56. TBINFO * ptbilParam);
  57. HRESULT HrOnFolderGetButtons(
  58. HWND hwnd,
  59. LPSHELLFOLDER psf,
  60. UINT idCmdFirst,
  61. LPTBBUTTON ptButton);
  62. HRESULT HrOnFolderInitMenuPopup(
  63. HWND hwnd,
  64. UINT idCmdFirst,
  65. INT iIndex,
  66. HMENU hmenu);
  67. HRESULT HrOnFolderMergeMenu(
  68. LPQCMINFO pqcm);
  69. HRESULT HrOnFolderInvokeCommand(
  70. HWND hwndOwner,
  71. WPARAM wParam,
  72. LPSHELLFOLDER psf);
  73. HRESULT HrCheckFolderInvokeCommand(
  74. HWND hwndOwner,
  75. WPARAM wParam,
  76. LPARAM lParam,
  77. BOOL bLevel,
  78. LPSHELLFOLDER psf);
  79. HRESULT HrOnFolderGetNotify(
  80. HWND hwndOwner,
  81. LPSHELLFOLDER psf,
  82. WPARAM wParam,
  83. LPARAM lParam);
  84. HRESULT HrOnGetHelpTopic(
  85. SFVM_HELPTOPIC_DATA * phtd);
  86. HRESULT HrOnGetCchMax(
  87. HWND hwnd,
  88. const PCONFOLDPIDL& pidl,
  89. INT * pcchMax);
  90. HRESULT HrOnGetHelpText(
  91. UINT idCmd,
  92. UINT cchMax,
  93. LPWSTR pszName);
  94. VOID TraceUnhandledMessages(
  95. UINT uMsg,
  96. LPARAM lParam,
  97. WPARAM wParam);
  98. //---[ Column struct and global array ]---------------------------------------
  99. COLS c_rgCols[] =
  100. {
  101. {ICOL_NAME, IDS_CONFOLD_DETAILS_NAME, 40, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT},
  102. {ICOL_TYPE, IDS_CONFOLD_DETAILS_TYPE, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT},
  103. {ICOL_STATUS, IDS_CONFOLD_DETAILS_STATUS, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT},
  104. {ICOL_DEVICE_NAME, IDS_CONFOLD_DETAILS_DEVICE_NAME, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT},
  105. {ICOL_PHONEORHOSTADDRESS, IDS_CONFOLD_DETAILS_PHONEORHOSTADDRESS, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT},
  106. {ICOL_OWNER, IDS_CONFOLD_DETAILS_OWNER, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT},
  107. {ICOL_ADDRESS, IDS_CONFOLD_DETAILS_ADDRESS, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_HIDDEN},
  108. {ICOL_PHONENUMBER, IDS_CONFOLD_DETAILS_PHONENUMBER, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_HIDDEN},
  109. {ICOL_HOSTADDRESS, IDS_CONFOLD_DETAILS_HOSTADDRESS, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_HIDDEN},
  110. {ICOL_WIRELESS_MODE, IDS_CONFOLD_DETAILS_WIRELESS_MODE, 24, LVCFMT_LEFT, SHCOLSTATE_TYPE_STR | SHCOLSTATE_HIDDEN},
  111. };
  112. #if DBG
  113. struct ShellViewTraceMsgEntry
  114. {
  115. UINT uMsg;
  116. CHAR szMsgName[32]; // Use Char because it's for Tracing only
  117. CHAR szLparamHint[32];
  118. CHAR szWparamHint[32];
  119. };
  120. static const ShellViewTraceMsgEntry c_SVTMEArray[] =
  121. {
  122. { DVM_GETBUTTONINFO , "DVM_GETBUTTONINFO" ,"TBINFO *" ,"-"} ,
  123. { DVM_GETBUTTONS , "DVM_GETBUTTONS" ,"idCmdFirst" ,"ptButton" },
  124. { DVM_COLUMNCLICK , "DVM_COLUMNCLICK" ,"-" ,"-" },
  125. { DVM_DEFVIEWMODE , "DVM_DEFVIEWMODE" ,"FOLDERVIEWMODE*" ,"-" },
  126. { DVM_DIDDRAGDROP , "DVM_DIDDRAGDROP" ,"-" ,"-" },
  127. { DVM_QUERYCOPYHOOK , "DVM_QUERYCOPYHOOK" ,"-" ,"-" },
  128. { DVM_SELCHANGE , "DVM_SELCHANGE" ,"-" ,"-" },
  129. { DVM_MERGEMENU , "DVM_MERGEMENU" ,"LPQCMINFO" ,"-" },
  130. { DVM_INITMENUPOPUP , "DVM_INITMENUPOPUP" ,"iIndex" ,"HMENU" },
  131. { DVM_REFRESH , "DVM_REFRESH" ,"-" ,"fPreRefresh" },
  132. { DVM_INVOKECOMMAND , "DVM_INVOKECOMMAND" ,"LPSHELLFOLDER" ,"wParam" },
  133. { SFVM_MERGEMENU , "SFVM_MERGEMENU" ,"0" ,"LPQCMINFO" },
  134. { SFVM_INVOKECOMMAND , "SFVM_INVOKECOMMAND" ,"idCmd" ,"0" },
  135. { SFVM_GETHELPTEXT , "SFVM_GETHELPTEXT" ,"idCmd,cchMax" ,"pszText - Ansi" },
  136. { SFVM_GETTOOLTIPTEXT , "SFVM_GETTOOLTIPTEXT" ,"idCmd,cchMax" ,"pszText - Ansi" },
  137. { SFVM_GETBUTTONINFO , "SFVM_GETBUTTONINFO" ,"0" ,"LPTBINFO" },
  138. { SFVM_GETBUTTONS , "SFVM_GETBUTTONS" ,"idCmdFirst,cbtnMax" ,"LPTBBUTTON" },
  139. { SFVM_INITMENUPOPUP , "SFVM_INITMENUPOPUP" ,"idCmdFirst,nIndex" ,"hmenu" },
  140. { SFVM_SELCHANGE , "SFVM_SELCHANGE" ,"idCmdFirst,nItem" ,"SFVM_SELCHANGE_DATA*" },
  141. { SFVM_DRAWITEM , "SFVM_DRAWITEM" ,"idCmdFirst" ,"DRAWITEMSTRUCT*" },
  142. { SFVM_MEASUREITEM , "SFVM_MEASUREITEM" ,"idCmdFirst" ,"MEASUREITEMSTRUCT*" },
  143. { SFVM_EXITMENULOOP , "SFVM_EXITMENULOOP" ,"-" ,"-" },
  144. { SFVM_PRERELEASE , "SFVM_PRERELEASE" ,"-" ,"-" },
  145. { SFVM_GETCCHMAX , "SFVM_GETCCHMAX" ,"LPCITEMIDLIST" ,"pcchMax" },
  146. { SFVM_FSNOTIFY , "SFVM_FSNOTIFY" ,"LPCITEMIDLIST*" ,"lEvent" },
  147. { SFVM_WINDOWCREATED , "SFVM_WINDOWCREATED" ,"hwnd" ,"-" },
  148. { SFVM_WINDOWDESTROY , "SFVM_WINDOWDESTROY" ,"hwnd" ,"-" },
  149. { SFVM_REFRESH , "SFVM_REFRESH" ,"BOOL fPreOrPost" ,"-" },
  150. { SFVM_SETFOCUS , "SFVM_SETFOCUS" ,"-" ,"-" },
  151. { SFVM_QUERYCOPYHOOK , "SFVM_QUERYCOPYHOOK" ,"-" ,"-" },
  152. { SFVM_NOTIFYCOPYHOOK , "SFVM_NOTIFYCOPYHOOK" ,"-" ,"COPYHOOKINFO*" },
  153. { SFVM_COLUMNCLICK , "SFVM_COLUMNCLICK" ,"iColumn" ,"-" },
  154. { SFVM_QUERYFSNOTIFY , "SFVM_QUERYFSNOTIFY" ,"-" ,"SHChangeNotifyEntry *" },
  155. { SFVM_DEFITEMCOUNT , "SFVM_DEFITEMCOUNT" ,"-" ,"UINT*" },
  156. { SFVM_DEFVIEWMODE , "SFVM_DEFVIEWMODE" ,"-" ,"FOLDERVIEWMODE*" },
  157. { SFVM_UNMERGEMENU , "SFVM_UNMERGEMENU" ,"-" ,"hmenu" },
  158. { SFVM_INSERTITEM , "SFVM_INSERTITEM" ,"pidl" ,"-" },
  159. { SFVM_DELETEITEM , "SFVM_DELETEITEM" ,"pidl" ,"-" },
  160. { SFVM_UPDATESTATUSBAR , "SFVM_UPDATESTATUSBAR" ,"fInitialize" ,"-" },
  161. { SFVM_BACKGROUNDENUM , "SFVM_BACKGROUNDENUM" ,"-" ,"-" },
  162. { SFVM_GETWORKINGDIR , "SFVM_GETWORKINGDIR" ,"uMax" ,"pszDir" },
  163. { SFVM_GETCOLSAVESTREAM , "SFVM_GETCOLSAVESTREAM" ,"flags" ,"IStream **" },
  164. { SFVM_SELECTALL , "SFVM_SELECTALL" ,"-" ,"-" },
  165. { SFVM_DIDDRAGDROP , "SFVM_DIDDRAGDROP" ,"dwEffect" ,"IDataObject *" },
  166. { SFVM_SUPPORTSIDENTITY , "SFVM_SUPPORTSIDENTITY" ,"-" ,"-" },
  167. { SFVM_FOLDERISPARENT , "SFVM_FOLDERISPARENT" ,"-" ,"pidlChild" },
  168. { SFVM_SETISFV , "SFVM_SETISFV" ,"-" ,"IShellFolderView*" },
  169. { SFVM_GETVIEWS , "SFVM_GETVIEWS" ,"SHELLVIEWID*" ,"IEnumSFVViews **" },
  170. { SFVM_THISIDLIST , "SFVM_THISIDLIST" ,"-" ,"LPITMIDLIST*" },
  171. { SFVM_GETITEMIDLIST , "SFVM_GETITEMIDLIST" ,"iItem" ,"LPITMIDLIST*" },
  172. { SFVM_SETITEMIDLIST , "SFVM_SETITEMIDLIST" ,"iItem" ,"LPITEMIDLIST" },
  173. { SFVM_INDEXOFITEMIDLIST , "SFVM_INDEXOFITEMIDLIST" ,"*iItem" ,"LPITEMIDLIST" },
  174. { SFVM_ODFINDITEM , "SFVM_ODFINDITEM" ,"*iItem" ,"NM_FINDITEM*" },
  175. { SFVM_HWNDMAIN , "SFVM_HWNDMAIN" ,"" ,"hwndMain" },
  176. { SFVM_ADDPROPERTYPAGES , "SFVM_ADDPROPERTYPAGES" ,"-" ,"SFVM_PROPPAGE_DATA *" },
  177. { SFVM_BACKGROUNDENUMDONE, "SFVM_BACKGROUNDENUMDONE","-" ,"-" },
  178. { SFVM_GETNOTIFY , "SFVM_GETNOTIFY" ,"LPITEMIDLIST*" ,"LONG*" },
  179. { SFVM_ARRANGE , "SFVM_ARRANGE" ,"-" ,"lParamSort" },
  180. { SFVM_QUERYSTANDARDVIEWS, "SFVM_QUERYSTANDARDVIEWS","-" ,"BOOL *" },
  181. { SFVM_QUERYREUSEEXTVIEW , "SFVM_QUERYREUSEEXTVIEW" ,"-" ,"BOOL *" },
  182. { SFVM_GETSORTDEFAULTS , "SFVM_GETSORTDEFAULTS" ,"iDirection" ,"iParamSort" },
  183. { SFVM_GETEMPTYTEXT , "SFVM_GETEMPTYTEXT" ,"cchMax" ,"pszText" },
  184. { SFVM_GETITEMICONINDEX , "SFVM_GETITEMICONINDEX" ,"iItem" ,"int *piIcon" },
  185. { SFVM_DONTCUSTOMIZE , "SFVM_DONTCUSTOMIZE" ,"-" ,"BOOL *pbDontCustomize" },
  186. { SFVM_SIZE , "SFVM_SIZE" ,"resizing flag" ,"cx, cy" },
  187. { SFVM_GETZONE , "SFVM_GETZONE" ,"-" ,"DWORD*" },
  188. { SFVM_GETPANE , "SFVM_GETPANE" ,"Pane ID" ,"DWORD*" },
  189. { SFVM_ISOWNERDATA , "SFVM_ISOWNERDATA" ,"ISOWNERDATA" ,"BOOL *" },
  190. { SFVM_GETODRANGEOBJECT , "SFVM_GETODRANGEOBJECT" ,"iWhich" ,"ILVRange **" },
  191. { SFVM_ODCACHEHINT , "SFVM_ODCACHEHINT" ,"-" ,"NMLVCACHEHINT *" },
  192. { SFVM_GETHELPTOPIC , "SFVM_GETHELPTOPIC" ,"0" ,"SFVM_HELPTOPIC_DATA *" },
  193. { SFVM_OVERRIDEITEMCOUNT , "SFVM_OVERRIDEITEMCOUNT" ,"-" ,"UINT*" },
  194. { SFVM_GETHELPTEXTW , "SFVM_GETHELPTEXTW" ,"idCmd,cchMax" ,"pszText - unicode" },
  195. { SFVM_GETTOOLTIPTEXTW , "SFVM_GETTOOLTIPTEXTW" ,"idCmd,cchMax" ,"pszText - unicode" },
  196. { SFVM_GETWEBVIEWLAYOUT , "SFVM_GETWEBVIEWLAYOUT" ,"SFVM_WEBVIEW_LAYOUT_DATA*", "uViewMode" },
  197. { SFVM_GETWEBVIEWTASKS , "SFVM_GETWEBVIEWTASKS" ,"SFVM_WEBVIEW_TASKSECTION_DATA*","pv" },
  198. { SFVM_GETWEBVIEWCONTENT , "SFVM_GETWEBVIEWCONTENT" ,"SFVM_WEBVIEW_CONTENT_DATA*", "pv" }
  199. };
  200. const INT g_iSVTMEArrayEntryCount = celems(c_SVTMEArray);
  201. VOID TraceShellViewMsg(
  202. UINT uMsg,
  203. LPARAM lParam,
  204. WPARAM wParam)
  205. {
  206. INT iLoop = 0;
  207. INT iFoundPos = -1;
  208. for (iLoop = 0; iLoop < g_iSVTMEArrayEntryCount && (-1 == iFoundPos); iLoop++)
  209. {
  210. if (c_SVTMEArray[iLoop].uMsg == uMsg)
  211. {
  212. iFoundPos = iLoop;
  213. }
  214. }
  215. if (-1 != iFoundPos)
  216. {
  217. UINT uMsg;
  218. CHAR szMsgName[32]; // Use Char because it's for Tracing only
  219. CHAR szLparamHint[32];
  220. CHAR szWparamHint[32];
  221. TraceTag(ttidShellViewMsgs,
  222. "%s (%d), lParam: 0x%08x [%s], wParam: 0x%08x [%s]",
  223. c_SVTMEArray[iFoundPos].szMsgName,
  224. c_SVTMEArray[iFoundPos].uMsg,
  225. lParam,
  226. c_SVTMEArray[iFoundPos].szLparamHint,
  227. wParam,
  228. c_SVTMEArray[iFoundPos].szWparamHint);
  229. }
  230. else
  231. {
  232. #ifdef SHOW_NEW_MSG_ASSERT
  233. AssertSz(FALSE,
  234. "Totally inert assert -- Unknown message in HrShellViewCallback. "
  235. "I just want to know about new ones");
  236. #endif
  237. TraceTag(ttidShellViewMsgs,
  238. "(Jeffspr) Unknown Message (%d) in HrShellViewCallback, lParam: 0x%08x, wParam, 0x%08x",
  239. uMsg, lParam, wParam);
  240. }
  241. }
  242. #endif
  243. //+---------------------------------------------------------------------------
  244. //
  245. // Member: CConnectionFolder::MessageSFVCB
  246. //
  247. // Purpose: Deferred Implementation of IShellViewCB::MessageSFVCB after
  248. // basic functionality was implemented.
  249. //
  250. // Arguments:
  251. // [uMsg] Message - depends on implementation
  252. // [wParam] WORD param - depends on implementation
  253. // [lParam] LONG param - - depends on implementation
  254. //
  255. // Returns: S_OK is succeeded
  256. // COM error code if not
  257. //
  258. // Author: deonb 8 Feb 2001
  259. //
  260. // Notes: CBaseShellFolderViewCB
  261. //
  262. STDMETHODIMP CConnectionFolder::RealMessage(
  263. UINT uMsg,
  264. WPARAM wParam,
  265. LPARAM lParam)
  266. {
  267. HRESULT hr = S_OK;
  268. TraceFileFunc(ttidShellFolder);
  269. #if DBG
  270. // Trace the shell message when we're in the checked builds
  271. //
  272. TraceShellViewMsg(uMsg, lParam, wParam);
  273. #endif
  274. switch (uMsg)
  275. {
  276. case DVM_GETBUTTONINFO:
  277. hr = HrOnFolderGetButtonInfo((TBINFO *)lParam);
  278. break;
  279. case DVM_GETBUTTONS:
  280. Assert(m_hwndMain);
  281. if (!m_hwndMain)
  282. {
  283. hr = E_UNEXPECTED;
  284. }
  285. else
  286. {
  287. hr = HrOnFolderGetButtons(m_hwndMain, this, LOWORD(wParam), (TBBUTTON *)lParam);
  288. }
  289. break;
  290. case DVM_COLUMNCLICK:
  291. Assert(m_hwndMain);
  292. if (!m_hwndMain)
  293. {
  294. hr = E_UNEXPECTED;
  295. }
  296. else
  297. {
  298. ShellFolderView_ReArrange (m_hwndMain, wParam);
  299. }
  300. break;
  301. case DVM_DEFVIEWMODE:
  302. *(FOLDERVIEWMODE *)lParam = FVM_TILE;
  303. break;
  304. case DVM_DIDDRAGDROP:
  305. case DVM_QUERYCOPYHOOK:
  306. case DVM_SELCHANGE:
  307. hr = S_FALSE;
  308. break;
  309. case DVM_MERGEMENU :
  310. hr = HrOnFolderMergeMenu((LPQCMINFO)lParam);
  311. break;
  312. case DVM_INITMENUPOPUP:
  313. Assert(m_hwndMain);
  314. if (!m_hwndMain)
  315. {
  316. hr = E_UNEXPECTED;
  317. }
  318. else
  319. {
  320. hr = HrOnFolderInitMenuPopup(m_hwndMain, LOWORD(wParam), HIWORD(wParam), (HMENU) lParam);
  321. }
  322. break;
  323. case DVM_REFRESH:
  324. Assert(m_hwndMain);
  325. if (!m_hwndMain)
  326. {
  327. hr = E_UNEXPECTED;
  328. }
  329. else
  330. {
  331. hr = HrOnFolderRefresh(m_hwndMain, lParam, wParam);
  332. }
  333. break;
  334. case DVM_INVOKECOMMAND:
  335. Assert(m_hwndMain);
  336. if (!m_hwndMain)
  337. {
  338. hr = E_UNEXPECTED;
  339. }
  340. else
  341. {
  342. hr = HrOnFolderInvokeCommand(m_hwndMain, wParam, this);
  343. }
  344. break;
  345. case MYWM_QUERYINVOKECOMMAND_ITEMLEVEL:
  346. Assert(m_hwndMain);
  347. if (!m_hwndMain)
  348. {
  349. hr = E_UNEXPECTED;
  350. }
  351. else
  352. {
  353. hr = HrCheckFolderInvokeCommand(m_hwndMain, wParam, lParam, FALSE, this);
  354. }
  355. break;
  356. case MYWM_QUERYINVOKECOMMAND_TOPLEVEL:
  357. Assert(m_hwndMain);
  358. if (!m_hwndMain)
  359. {
  360. hr = E_UNEXPECTED;
  361. }
  362. else
  363. {
  364. hr = HrCheckFolderInvokeCommand(m_hwndMain, wParam, lParam, TRUE, this);
  365. }
  366. break;
  367. case SFVM_HWNDMAIN:
  368. m_hwndMain = (HWND)lParam;
  369. HrAssertMenuStructuresValid(m_hwndMain);
  370. break;
  371. case SFVM_GETDEFERREDVIEWSETTINGS:
  372. ((SFVM_DEFERRED_VIEW_SETTINGS *)lParam)->fvm = FVM_TILE;
  373. break;
  374. case SFVM_GETNOTIFY:
  375. Assert(m_hwndMain);
  376. if (!m_hwndMain)
  377. {
  378. hr = E_UNEXPECTED;
  379. }
  380. else
  381. {
  382. hr = HrOnFolderGetNotify(m_hwndMain, this, wParam, lParam);
  383. }
  384. break;
  385. case SFVM_GETHELPTOPIC:
  386. hr = HrOnGetHelpTopic((SFVM_HELPTOPIC_DATA*)lParam);
  387. break;
  388. case SFVM_GETCCHMAX:
  389. Assert(m_hwndMain);
  390. if (!m_hwndMain)
  391. {
  392. hr = E_UNEXPECTED;
  393. }
  394. else
  395. {
  396. PCONFOLDPIDL pidlParm;
  397. if (FAILED(pidlParm.InitializeFromItemIDList((LPCITEMIDLIST) wParam)))
  398. {
  399. return E_INVALIDARG;
  400. }
  401. hr = HrOnGetCchMax(m_hwndMain, pidlParm, (INT *) lParam);
  402. }
  403. break;
  404. case SFVM_GETHELPTEXTW:
  405. hr = HrOnGetHelpText(LOWORD(wParam), HIWORD(wParam), reinterpret_cast<PWSTR>(lParam));
  406. break;
  407. default:
  408. hr = m_pWebView->RealMessage(uMsg, wParam, lParam); // defer to the webview's handler
  409. break;
  410. }
  411. return hr;
  412. }
  413. //+---------------------------------------------------------------------------
  414. //
  415. // Function: HrOnGetHelpText
  416. //
  417. // Purpose: Folder message handler for defview's SFVM_GETHELPTEXTW. This
  418. // message is received when the status bar text for a command is needed.
  419. //
  420. // Arguments:
  421. // idCmd [in] Id of the menu command
  422. // cchMax [in] Size of buffer
  423. // pszName [out] Status bar text
  424. //
  425. // Returns:
  426. //
  427. // Author: mbend 3 May 2000
  428. //
  429. // Notes:
  430. //
  431. HRESULT HrOnGetHelpText(UINT idCmd, UINT cchMax, PWSTR pszName)
  432. {
  433. HRESULT hr = E_FAIL;
  434. *((PWSTR)pszName) = L'\0';
  435. int iLength = LoadString( _Module.GetResourceInstance(),
  436. idCmd + IDS_CMIDM_START,
  437. (PWSTR) pszName,
  438. cchMax);
  439. if (iLength > 0)
  440. {
  441. hr = NOERROR;
  442. }
  443. else
  444. {
  445. AssertSz(FALSE, "Resource string not found for one of the connections folder commands");
  446. }
  447. return hr;
  448. }
  449. //+---------------------------------------------------------------------------
  450. //
  451. // Function: HrOnGetCchMax
  452. //
  453. // Purpose: Folder message handler for defview's SFVM_GETCCHMAX. This
  454. // message is received when a rename is attempted, and causes
  455. // the edit control to be limited to the size returned.
  456. //
  457. // Arguments:
  458. // hwnd [in] Folder window handle
  459. // pidl [in] The object pidl
  460. // pcchMax [out] Return pointer for max name length
  461. //
  462. // Returns:
  463. //
  464. // Author: jeffspr 21 Jul 1998
  465. //
  466. // Notes:
  467. //
  468. HRESULT HrOnGetCchMax(HWND hwnd, const PCONFOLDPIDL& pidl, INT * pcchMax)
  469. {
  470. HRESULT hr = S_OK;
  471. Assert(!pidl.empty());
  472. Assert(pcchMax);
  473. // If the passed in info is valid
  474. //
  475. if ( (!pidl.empty()) && pcchMax && pidl->IsPidlOfThisType() )
  476. {
  477. // Set the max to be the max length of a RAS entry. Currently,
  478. // that's our only requirement
  479. //
  480. *pcchMax = RAS_MaxEntryName;
  481. }
  482. else
  483. {
  484. hr = E_INVALIDARG;
  485. }
  486. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnGetCchMax");
  487. return hr;
  488. }
  489. //+---------------------------------------------------------------------------
  490. //
  491. // Function: HrOnFolderRefresh
  492. //
  493. // Purpose: Folder message handler for defview's DVM_REFRESH
  494. //
  495. // Arguments:
  496. // hwndOwner [in] Our parent window
  497. // lParam [in] Ignored
  498. // wParam [in] BOOL -- TRUE = Pre-refresh, FALSE = Post-refresh
  499. //
  500. // Returns:
  501. //
  502. // Author: jeffspr 10 Apr 1998
  503. //
  504. // Notes:
  505. //
  506. HRESULT HrOnFolderRefresh(
  507. HWND hwndOwner,
  508. LPARAM lParam,
  509. WPARAM wParam)
  510. {
  511. TraceFileFunc(ttidShellFolder);
  512. HRESULT hr = S_OK;
  513. BOOL fPreRefresh = (wParam > 0);
  514. // If this refresh notification is coming BEFORE the refresh, then we want to
  515. // flush the connection list. Two reasons for this:
  516. //
  517. // 1: We don't ever want to re-enumerate AFTER the refresh has occurred.
  518. // 2: We get a POST refresh notify on folder entry, which shouldn't necessitate
  519. // a refresh
  520. //
  521. if (fPreRefresh)
  522. {
  523. // Rebuild the cache
  524. //
  525. // Note: Remove this when we get RAS notifications, because
  526. // we will already know about the CM connections and won't have to refresh.
  527. // Revert the #if 0'd code above to just do the fPreRefresh flush.
  528. //
  529. hr = g_ccl.HrRefreshConManEntries();
  530. if (FAILED(hr))
  531. {
  532. NcMsgBox(_Module.GetResourceInstance(),
  533. NULL,
  534. IDS_CONFOLD_WARNING_CAPTION,
  535. IDS_ERR_NO_NETMAN,
  536. MB_ICONEXCLAMATION | MB_OK);
  537. }
  538. }
  539. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderRefresh");
  540. return hr;
  541. }
  542. //+---------------------------------------------------------------------------
  543. //
  544. // Function: HrOnFolderGetNotify
  545. //
  546. // Purpose: Folder message handler for defview's DVM_GETNOTIFY
  547. //
  548. // Arguments:
  549. // hwndOwner [in] Our parent window
  550. // psf [in] Our shell folder
  551. // wParam [out] Return pointer for our folder pidl
  552. // lParam [out] Return pointer for notify flags
  553. //
  554. // Returns:
  555. //
  556. // Author: jeffspr 10 Apr 1998
  557. //
  558. // Notes:
  559. //
  560. HRESULT HrOnFolderGetNotify(
  561. HWND hwndOwner,
  562. LPSHELLFOLDER psf,
  563. WPARAM wParam,
  564. LPARAM lParam)
  565. {
  566. HRESULT hr = S_OK;
  567. CConnectionFolder * pcf = static_cast<CConnectionFolder *>(psf);
  568. PCONFOLDPIDLFOLDER pidlRoot;
  569. PCONFOLDPIDLFOLDER pidlRootCopy;
  570. NETCFG_TRY
  571. if (!psf || !wParam || !lParam)
  572. {
  573. Assert(psf);
  574. Assert(lParam);
  575. Assert(wParam);
  576. hr = E_INVALIDARG;
  577. }
  578. else
  579. {
  580. pidlRoot = pcf->PidlGetFolderRoot();
  581. if (pidlRoot.empty())
  582. {
  583. hr = E_FAIL;
  584. }
  585. else
  586. {
  587. hr = pidlRootCopy.ILClone(pidlRoot);
  588. if (SUCCEEDED(hr))
  589. {
  590. *(LPCITEMIDLIST*)wParam = pidlRootCopy.TearOffItemIdList();
  591. *(LONG*)lParam =
  592. SHCNE_RENAMEITEM|
  593. SHCNE_CREATE |
  594. SHCNE_DELETE |
  595. SHCNE_UPDATEDIR |
  596. SHCNE_UPDATEITEM;
  597. }
  598. }
  599. }
  600. NETCFG_CATCH(hr)
  601. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderGetNotify");
  602. return hr;
  603. }
  604. //+---------------------------------------------------------------------------
  605. //
  606. // Function: HrOnGetHelpTopic
  607. //
  608. // Purpose: Folder message handler for defview's SFVM_GETHELPTOPIC
  609. //
  610. // Arguments:
  611. // phtd [in out] Pointer to SFVM_HELPTOPIC_DATA structure with default values set
  612. //
  613. // Returns:
  614. // S_OK Help file name is correctly set
  615. //
  616. // Author: toddb 21 Jun 1998
  617. //
  618. // Notes:
  619. //
  620. HRESULT HrOnGetHelpTopic(
  621. SFVM_HELPTOPIC_DATA * phtd)
  622. {
  623. Assert(phtd);
  624. Assert(phtd->wszHelpFile);
  625. *(phtd->wszHelpFile) = L'\0';
  626. Assert(phtd->wszHelpTopic);
  627. lstrcpyW(phtd->wszHelpTopic, L"hcp://services/subsite?node=Unmapped/Network_connections&select=Unmapped/Network_connections/Getting_started");
  628. return S_OK;
  629. }
  630. //+---------------------------------------------------------------------------
  631. //
  632. // Function: HrOnFolderInvokeCommand
  633. //
  634. // Purpose: Folder message handler for defview's DVM_INVOKECOMMAND
  635. //
  636. // Arguments:
  637. // hwndOwner [in] Our window handle
  638. // wParam [in] Command that's being invoked
  639. // psf [in] Our shell folder
  640. //
  641. // Returns:
  642. //
  643. // Author: jeffspr 10 Apr 1998
  644. //
  645. // Notes:
  646. //
  647. HRESULT HrOnFolderInvokeCommand(
  648. HWND hwndOwner,
  649. WPARAM wParam,
  650. LPSHELLFOLDER psf)
  651. {
  652. HRESULT hr = S_OK;
  653. PCONFOLDPIDLVEC apidlSelected;
  654. PCONFOLDPIDLVEC apidlCache;
  655. // Get the selected objects. If there are objects present, try to get them from the
  656. // cache. Regardless, call the command handler
  657. //
  658. hr = HrShellView_GetSelectedObjects(hwndOwner, apidlSelected);
  659. if (SUCCEEDED(hr))
  660. {
  661. // If there are objects, try to get the cached versions
  662. //
  663. if (!apidlSelected.empty())
  664. {
  665. hr = HrCloneRgIDL(apidlSelected, TRUE, TRUE, apidlCache);
  666. }
  667. // If either the clone succeeded, or there were no items, call the command handler
  668. //
  669. if (SUCCEEDED(hr))
  670. {
  671. hr = HrFolderCommandHandler(
  672. (UINT) wParam,
  673. apidlCache,
  674. hwndOwner,
  675. NULL,
  676. psf);
  677. }
  678. }
  679. TraceHr(ttidError, FAL, hr, FALSE, "HrOnFolderInvokeCommand");
  680. return hr;
  681. }
  682. //+---------------------------------------------------------------------------
  683. //
  684. // Function: HrCheckFolderInvokeCommand
  685. //
  686. // Purpose: Test if a message handler can be invoked
  687. //
  688. // Arguments:
  689. // hwndOwner [in] Our window handle
  690. // wParam [in] Command that's being invoked
  691. // psf [in] Our shell folder
  692. //
  693. // Returns:
  694. //
  695. // Author: deonb 10 Feb 2001
  696. //
  697. // Notes:
  698. //
  699. HRESULT HrCheckFolderInvokeCommand(
  700. HWND hwndOwner,
  701. WPARAM wParam,
  702. LPARAM lParam,
  703. BOOL bLevel,
  704. LPSHELLFOLDER psf)
  705. {
  706. HRESULT hr = S_OK;
  707. PCONFOLDPIDLVEC apidlSelected;
  708. PCONFOLDPIDLVEC apidlCache;
  709. // Get the selected objects. If there are objects present, try to get them from the
  710. // cache. Regardless, call the command handler
  711. //
  712. hr = HrShellView_GetSelectedObjects(hwndOwner, apidlSelected);
  713. if (SUCCEEDED(hr))
  714. {
  715. // If there are objects, try to get the cached versions
  716. //
  717. if (!apidlSelected.empty())
  718. {
  719. hr = HrCloneRgIDL(apidlSelected, TRUE, TRUE, apidlCache);
  720. }
  721. // If either the clone succeeded, or there were no items, call the command handler
  722. //
  723. if (SUCCEEDED(hr))
  724. {
  725. DWORD dwVerbId = wParam;
  726. NCCS_STATE *nccsState = reinterpret_cast<NCCS_STATE *>(lParam);
  727. DWORD dwResourceId;
  728. hr = HrGetCommandState(apidlCache, dwVerbId, *nccsState, &dwResourceId, 0xFFFFFFFF, bLevel ? NB_FLAG_ON_TOPMENU : NB_NO_FLAGS);
  729. }
  730. }
  731. TraceHr(ttidError, FAL, hr, FALSE, "HrOnFolderInvokeCommand");
  732. return hr;
  733. }
  734. //+---------------------------------------------------------------------------
  735. //
  736. // Function: HrOnFolderInitMenuPopup
  737. //
  738. // Purpose: Folder message handler for defview's DVM_INITMENUPOPUP
  739. //
  740. // Arguments:
  741. // hwnd [] Our window handle
  742. // idCmdFirst [] First command ID in the menu
  743. // iIndex [] ???
  744. // hmenu [] Our menu handle
  745. //
  746. // Returns:
  747. //
  748. // Author: jeffspr 13 Jan 1998
  749. //
  750. // Notes:
  751. //
  752. HRESULT HrOnFolderInitMenuPopup(
  753. HWND hwnd,
  754. UINT idCmdFirst,
  755. INT iIndex,
  756. HMENU hmenu)
  757. {
  758. HRESULT hr = S_OK;
  759. PCONFOLDPIDLVEC apidlSelected;
  760. PCONFOLDPIDLVEC apidlCache;
  761. // Get the currently selected object
  762. //
  763. hr = HrShellView_GetSelectedObjects(hwnd, apidlSelected);
  764. if (SUCCEEDED(hr))
  765. {
  766. // If we have a selection, clone it. Otherwise, we can live with a NULL apidlCache
  767. // (HrSetConnectDisconnectMenuItem and HrEnableOrDisableMenuItems both allow
  768. // NULL pidl arrays
  769. //
  770. if (!apidlSelected.empty())
  771. {
  772. // Clone the pidl array using the cache
  773. //
  774. hr = HrCloneRgIDL(apidlSelected, TRUE, TRUE, apidlCache);
  775. if (FAILED(hr))
  776. {
  777. TraceHr(ttidError, FAL, hr, FALSE, "HrCloneRgIDL failed on apidl in "
  778. "HrOnFolderInitMenuPopup");
  779. }
  780. }
  781. // Only do this for the file menu (iIndex=0)
  782. if(0 == iIndex)
  783. {
  784. // Ignore the return from this, since we want to do both regardless.
  785. // We retrieve this value for debugging purposes only
  786. //
  787. hr = HrSetConnectDisconnectMenuItem(apidlCache, hmenu, idCmdFirst);
  788. if (FAILED(hr))
  789. {
  790. AssertSz(FALSE, "Failed to set the connect/disconnect menu items");
  791. }
  792. }
  793. HrUpdateMenu(hmenu, apidlCache, idCmdFirst);
  794. }
  795. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderInitMenuPopup");
  796. return hr;
  797. }
  798. HRESULT HrOnFolderMergeMenu(LPQCMINFO pqcm)
  799. {
  800. HRESULT hr = S_OK;
  801. HMENU hmenu = NULL;
  802. hmenu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(MENU_MERGE_INBOUND_DISCON));
  803. if (hmenu)
  804. {
  805. MergeMenu(_Module.GetResourceInstance(), POPUP_MERGE_FOLDER_CONNECTIONS, MENU_MERGE_INBOUND_DISCON, pqcm);
  806. DestroyMenu(hmenu);
  807. }
  808. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderMergeMenu");
  809. return S_OK;
  810. }
  811. //+---------------------------------------------------------------------------
  812. //
  813. // Function: HrOnFolderGetButtons
  814. //
  815. // Purpose: Folder message handler for defview's DVM_GETBUTTONS
  816. //
  817. // Arguments:
  818. // hwnd [in] Folder window handle
  819. // psf [in] Pointer to the IShellFolder interface
  820. // idCmdFirst [in] Our command ID base
  821. // ptButton [in/out] Button structures to fill
  822. //
  823. // Returns:
  824. //
  825. // Author: jeffspr 15 Dec 1997
  826. //
  827. // Notes:
  828. //
  829. HRESULT HrOnFolderGetButtons(
  830. HWND hwnd,
  831. LPSHELLFOLDER psf,
  832. UINT idCmdFirst,
  833. LPTBBUTTON ptButton)
  834. {
  835. HRESULT hr = S_OK;
  836. #if ANY_FREEKIN_THING_IN_TOOLBAR
  837. UINT i = 0;
  838. LRESULT iBtnOffset = 0;
  839. IShellBrowser * psb = FileCabinet_GetIShellBrowser(hwnd);
  840. TBADDBITMAP ab;
  841. PWSTR pszToolbarStrings[2];
  842. for (DWORD dwLoop = 0; dwLoop < c_nToolbarButtons; dwLoop++)
  843. {
  844. // If this isn't a separator, load the text/tip string
  845. //
  846. if (!(c_tbConnections[dwLoop].fsStyle & TBSTYLE_SEP))
  847. {
  848. Assert(c_tbConnections[dwLoop].iString != -1);
  849. pszToolbarStrings[dwLoop] = (PWSTR) SzLoadIds(c_tbConnections[dwLoop].iString);
  850. }
  851. }
  852. // Add the toolbar button bitmap, get it's offset
  853. //
  854. ab.hInst = _Module.GetResourceInstance();
  855. ab.nID = IDB_TB_SMALL; // std bitmaps
  856. hr = psb->SendControlMsg(FCW_TOOLBAR, TB_ADDBITMAP, c_nToolbarButtons,
  857. (LONG_PTR)&ab, &iBtnOffset);
  858. if (SUCCEEDED(hr))
  859. {
  860. for (i = 0; i < c_nToolbarButtons; i++)
  861. {
  862. ptButton[i] = c_tbConnections[i];
  863. if (!(c_tbConnections[i].fsStyle & TBSTYLE_SEP))
  864. {
  865. ptButton[i].idCommand += idCmdFirst;
  866. ptButton[i].iBitmap += (int) iBtnOffset;
  867. ptButton[i].iString = (INT_PTR) pszToolbarStrings[i];
  868. }
  869. }
  870. }
  871. #endif // ANY_FREEKIN_THING_IN_TOOLBAR
  872. // We always want to return success, even if we added nothing.
  873. //
  874. return S_OK;
  875. }
  876. //+---------------------------------------------------------------------------
  877. //
  878. // Function: HrOnFolderGetButtonInfo
  879. //
  880. // Purpose: Folder message handler for defview's DVM_GETBUTTONINFO
  881. //
  882. // Arguments:
  883. // ptbInfo [in/out] Structure that we'll fill in (flags and button
  884. // count)
  885. //
  886. // Returns:
  887. //
  888. // Author: jeffspr 15 Dec 1997
  889. //
  890. // Notes:
  891. //
  892. HRESULT HrOnFolderGetButtonInfo(TBINFO * ptbInfo)
  893. {
  894. ptbInfo->uFlags = TBIF_PREPEND;
  895. ptbInfo->cbuttons = c_nToolbarButtons; // size of toolbar array
  896. return S_OK;
  897. }