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.

1022 lines
35 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. IN HWND hwndOwner,
  53. IN LPARAM lParam,
  54. IN WPARAM wParam);
  55. HRESULT HrOnFolderGetButtonInfo(
  56. IN OUT TBINFO * ptbilParam);
  57. HRESULT HrOnFolderGetButtons(
  58. IN HWND hwnd,
  59. IN LPSHELLFOLDER psf,
  60. IN UINT idCmdFirst,
  61. IN OUT LPTBBUTTON ptButton);
  62. HRESULT HrOnFolderInitMenuPopup(
  63. IN HWND hwnd,
  64. IN UINT idCmdFirst,
  65. IN INT iIndex,
  66. IN HMENU hmenu);
  67. HRESULT HrOnFolderMergeMenu(
  68. IN OUT LPQCMINFO pqcm);
  69. HRESULT HrOnFolderInvokeCommand(
  70. IN HWND hwndOwner,
  71. IN WPARAM wParam,
  72. IN LPSHELLFOLDER psf);
  73. HRESULT HrCheckFolderInvokeCommand(
  74. IN HWND hwndOwner,
  75. IN WPARAM wParam,
  76. IN LPARAM lParam,
  77. IN BOOL bLevel,
  78. IN LPSHELLFOLDER psf);
  79. HRESULT HrOnFolderGetNotify(
  80. IN HWND hwndOwner,
  81. IN LPSHELLFOLDER psf,
  82. IN WPARAM wParam,
  83. IN LPARAM lParam);
  84. HRESULT HrOnGetHelpTopic(
  85. OUT SFVM_HELPTOPIC_DATA * phtd);
  86. HRESULT HrOnGetCchMax(
  87. IN HWND hwnd,
  88. IN const PCONFOLDPIDL& pidl,
  89. OUT INT * pcchMax);
  90. HRESULT HrOnGetHelpText(
  91. IN UINT idCmd,
  92. IN UINT cchMax,
  93. OUT LPWSTR pszName);
  94. VOID TraceUnhandledMessages(
  95. IN UINT uMsg,
  96. IN LPARAM lParam,
  97. IN 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. IN UINT uMsg,
  203. IN LPARAM lParam,
  204. IN 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 [in] Message - depends on implementation
  252. // wParam [in] WORD param - depends on implementation
  253. // lParam [in] 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. IN UINT uMsg,
  264. IN WPARAM wParam,
  265. IN 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(IN UINT idCmd,
  432. IN UINT cchMax,
  433. OUT PWSTR pszName)
  434. {
  435. HRESULT hr = E_FAIL;
  436. *((PWSTR)pszName) = L'\0';
  437. int iLength = LoadString( _Module.GetResourceInstance(),
  438. idCmd + IDS_CMIDM_START,
  439. (PWSTR) pszName,
  440. cchMax);
  441. if (iLength > 0)
  442. {
  443. hr = NOERROR;
  444. }
  445. else
  446. {
  447. AssertSz(FALSE, "Resource string not found for one of the connections folder commands");
  448. }
  449. return hr;
  450. }
  451. //+---------------------------------------------------------------------------
  452. //
  453. // Function: HrOnGetCchMax
  454. //
  455. // Purpose: Folder message handler for defview's SFVM_GETCCHMAX. This
  456. // message is received when a rename is attempted, and causes
  457. // the edit control to be limited to the size returned.
  458. //
  459. // Arguments:
  460. // hwnd [in] Folder window handle
  461. // pidl [in] The object pidl
  462. // pcchMax [out] Return pointer for max name length
  463. //
  464. // Returns:
  465. //
  466. // Author: jeffspr 21 Jul 1998
  467. //
  468. // Notes:
  469. //
  470. HRESULT HrOnGetCchMax(IN HWND hwnd,
  471. IN const PCONFOLDPIDL& pidl,
  472. OUT INT * pcchMax)
  473. {
  474. HRESULT hr = S_OK;
  475. Assert(!pidl.empty());
  476. Assert(pcchMax);
  477. // If the passed in info is valid
  478. //
  479. if ( (!pidl.empty()) && pcchMax && pidl->IsPidlOfThisType() )
  480. {
  481. // Set the max to be the max length of a RAS entry. Currently,
  482. // that's our only requirement
  483. //
  484. *pcchMax = RAS_MaxEntryName;
  485. }
  486. else
  487. {
  488. hr = E_INVALIDARG;
  489. }
  490. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnGetCchMax");
  491. return hr;
  492. }
  493. //+---------------------------------------------------------------------------
  494. //
  495. // Function: HrOnFolderRefresh
  496. //
  497. // Purpose: Folder message handler for defview's DVM_REFRESH
  498. //
  499. // Arguments:
  500. // hwndOwner [in] Our parent window
  501. // lParam [in] Ignored
  502. // wParam [in] BOOL -- TRUE = Pre-refresh, FALSE = Post-refresh
  503. //
  504. // Returns:
  505. //
  506. // Author: jeffspr 10 Apr 1998
  507. //
  508. // Notes:
  509. //
  510. HRESULT HrOnFolderRefresh(
  511. IN HWND hwndOwner,
  512. IN LPARAM lParam,
  513. IN WPARAM wParam)
  514. {
  515. TraceFileFunc(ttidShellFolder);
  516. HRESULT hr = S_OK;
  517. BOOL fPreRefresh = (wParam > 0);
  518. // If this refresh notification is coming BEFORE the refresh, then we want to
  519. // flush the connection list. Two reasons for this:
  520. //
  521. // 1: We don't ever want to re-enumerate AFTER the refresh has occurred.
  522. // 2: We get a POST refresh notify on folder entry, which shouldn't necessitate
  523. // a refresh
  524. //
  525. if (fPreRefresh)
  526. {
  527. // Rebuild the cache
  528. //
  529. // Note: Remove this when we get RAS notifications, because
  530. // we will already know about the CM connections and won't have to refresh.
  531. // Revert the #if 0'd code above to just do the fPreRefresh flush.
  532. //
  533. hr = g_ccl.HrRefreshConManEntries();
  534. if (FAILED(hr))
  535. {
  536. NcMsgBox(_Module.GetResourceInstance(),
  537. NULL,
  538. IDS_CONFOLD_WARNING_CAPTION,
  539. IDS_ERR_NO_NETMAN,
  540. MB_ICONEXCLAMATION | MB_OK);
  541. }
  542. }
  543. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderRefresh");
  544. return hr;
  545. }
  546. //+---------------------------------------------------------------------------
  547. //
  548. // Function: HrOnFolderGetNotify
  549. //
  550. // Purpose: Folder message handler for defview's DVM_GETNOTIFY
  551. //
  552. // Arguments:
  553. // hwndOwner [in] Our parent window
  554. // psf [in] Our shell folder
  555. // wParam [out] Return pointer for our folder pidl
  556. // lParam [out] Return pointer for notify flags
  557. //
  558. // Returns:
  559. //
  560. // Author: jeffspr 10 Apr 1998
  561. //
  562. // Notes:
  563. //
  564. HRESULT HrOnFolderGetNotify(
  565. IN HWND hwndOwner,
  566. IN LPSHELLFOLDER psf,
  567. IN WPARAM wParam,
  568. IN LPARAM lParam)
  569. {
  570. HRESULT hr = S_OK;
  571. CConnectionFolder * pcf = static_cast<CConnectionFolder *>(psf);
  572. PCONFOLDPIDLFOLDER pidlRoot;
  573. PCONFOLDPIDLFOLDER pidlRootCopy;
  574. NETCFG_TRY
  575. if (!psf || !wParam || !lParam)
  576. {
  577. Assert(psf);
  578. Assert(lParam);
  579. Assert(wParam);
  580. hr = E_INVALIDARG;
  581. }
  582. else
  583. {
  584. pidlRoot = pcf->PidlGetFolderRoot();
  585. if (pidlRoot.empty())
  586. {
  587. hr = E_FAIL;
  588. }
  589. else
  590. {
  591. hr = pidlRootCopy.ILClone(pidlRoot);
  592. if (SUCCEEDED(hr))
  593. {
  594. *(LPCITEMIDLIST*)wParam = pidlRootCopy.TearOffItemIdList();
  595. *(LONG*)lParam =
  596. SHCNE_RENAMEITEM|
  597. SHCNE_CREATE |
  598. SHCNE_DELETE |
  599. SHCNE_UPDATEDIR |
  600. SHCNE_UPDATEITEM;
  601. }
  602. }
  603. }
  604. NETCFG_CATCH(hr)
  605. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderGetNotify");
  606. return hr;
  607. }
  608. //+---------------------------------------------------------------------------
  609. //
  610. // Function: HrOnGetHelpTopic
  611. //
  612. // Purpose: Folder message handler for defview's SFVM_GETHELPTOPIC
  613. //
  614. // Arguments:
  615. // phtd [in out] Pointer to SFVM_HELPTOPIC_DATA structure with default values set
  616. //
  617. // Returns:
  618. // S_OK Help file name is correctly set
  619. //
  620. // Author: toddb 21 Jun 1998
  621. //
  622. // Notes:
  623. //
  624. HRESULT HrOnGetHelpTopic(
  625. OUT SFVM_HELPTOPIC_DATA * phtd)
  626. {
  627. Assert(phtd);
  628. Assert(phtd->wszHelpFile);
  629. if (IsOS(OS_PROFESSIONAL) || IsOS(OS_PERSONAL))
  630. {
  631. *(phtd->wszHelpFile) = L'\0';
  632. Assert(phtd->wszHelpTopic);
  633. lstrcpyW(phtd->wszHelpTopic, L"hcp://services/subsite?node=Unmapped/Network_connections&select=Unmapped/Network_connections/Getting_started");
  634. }
  635. else
  636. {
  637. static LPCWSTR szNetCfgHelpFile = L"netcfg.chm";
  638. lstrcpyW(phtd->wszHelpFile, szNetCfgHelpFile);
  639. }
  640. return S_OK;
  641. }
  642. //+---------------------------------------------------------------------------
  643. //
  644. // Function: HrOnFolderInvokeCommand
  645. //
  646. // Purpose: Folder message handler for defview's DVM_INVOKECOMMAND
  647. //
  648. // Arguments:
  649. // hwndOwner [in] Our window handle
  650. // wParam [in] Command that's being invoked
  651. // psf [in] Our shell folder
  652. //
  653. // Returns:
  654. //
  655. // Author: jeffspr 10 Apr 1998
  656. //
  657. // Notes:
  658. //
  659. HRESULT HrOnFolderInvokeCommand(
  660. IN HWND hwndOwner,
  661. IN WPARAM wParam,
  662. IN LPSHELLFOLDER psf)
  663. {
  664. HRESULT hr = S_OK;
  665. PCONFOLDPIDLVEC apidlSelected;
  666. PCONFOLDPIDLVEC apidlCache;
  667. // Get the selected objects. If there are objects present, try to get them from the
  668. // cache. Regardless, call the command handler
  669. //
  670. hr = HrShellView_GetSelectedObjects(hwndOwner, apidlSelected);
  671. if (SUCCEEDED(hr))
  672. {
  673. // If there are objects, try to get the cached versions
  674. //
  675. if (!apidlSelected.empty())
  676. {
  677. hr = HrCloneRgIDL(apidlSelected, TRUE, TRUE, apidlCache);
  678. }
  679. // If either the clone succeeded, or there were no items, call the command handler
  680. //
  681. if (SUCCEEDED(hr))
  682. {
  683. hr = HrFolderCommandHandler(
  684. (UINT) wParam,
  685. apidlCache,
  686. hwndOwner,
  687. NULL,
  688. psf);
  689. }
  690. }
  691. TraceHr(ttidError, FAL, hr, FALSE, "HrOnFolderInvokeCommand");
  692. return hr;
  693. }
  694. //+---------------------------------------------------------------------------
  695. //
  696. // Function: HrCheckFolderInvokeCommand
  697. //
  698. // Purpose: Test if a message handler can be invoked
  699. //
  700. // Arguments:
  701. // hwndOwner [in] Our window handle
  702. // wParam [in] Command that's being invoked
  703. // psf [in] Our shell folder
  704. //
  705. // Returns:
  706. //
  707. // Author: deonb 10 Feb 2001
  708. //
  709. // Notes:
  710. //
  711. HRESULT HrCheckFolderInvokeCommand(
  712. IN HWND hwndOwner,
  713. IN WPARAM wParam,
  714. IN LPARAM lParam,
  715. IN BOOL bLevel,
  716. IN LPSHELLFOLDER psf)
  717. {
  718. HRESULT hr = S_OK;
  719. PCONFOLDPIDLVEC apidlSelected;
  720. PCONFOLDPIDLVEC apidlCache;
  721. // Get the selected objects. If there are objects present, try to get them from the
  722. // cache. Regardless, call the command handler
  723. //
  724. hr = HrShellView_GetSelectedObjects(hwndOwner, apidlSelected);
  725. if (SUCCEEDED(hr))
  726. {
  727. // If there are objects, try to get the cached versions
  728. //
  729. if (!apidlSelected.empty())
  730. {
  731. hr = HrCloneRgIDL(apidlSelected, TRUE, TRUE, apidlCache);
  732. }
  733. // If either the clone succeeded, or there were no items, call the command handler
  734. //
  735. if (SUCCEEDED(hr))
  736. {
  737. DWORD dwVerbId = (DWORD)wParam;
  738. NCCS_STATE *nccsState = reinterpret_cast<NCCS_STATE *>(lParam);
  739. DWORD dwResourceId;
  740. hr = HrGetCommandState(apidlCache, dwVerbId, *nccsState, &dwResourceId, 0xFFFFFFFF, bLevel ? NB_FLAG_ON_TOPMENU : NB_NO_FLAGS);
  741. }
  742. }
  743. TraceHr(ttidError, FAL, hr, FALSE, "HrOnFolderInvokeCommand");
  744. return hr;
  745. }
  746. //+---------------------------------------------------------------------------
  747. //
  748. // Function: HrOnFolderInitMenuPopup
  749. //
  750. // Purpose: Folder message handler for defview's DVM_INITMENUPOPUP
  751. //
  752. // Arguments:
  753. // hwnd [] Our window handle
  754. // idCmdFirst [] First command ID in the menu
  755. // iIndex [] ???
  756. // hmenu [] Our menu handle
  757. //
  758. // Returns:
  759. //
  760. // Author: jeffspr 13 Jan 1998
  761. //
  762. // Notes:
  763. //
  764. HRESULT HrOnFolderInitMenuPopup(
  765. IN HWND hwnd,
  766. IN UINT idCmdFirst,
  767. IN INT iIndex,
  768. IN HMENU hmenu)
  769. {
  770. HRESULT hr = S_OK;
  771. PCONFOLDPIDLVEC apidlSelected;
  772. PCONFOLDPIDLVEC apidlCache;
  773. // Get the currently selected object
  774. //
  775. hr = HrShellView_GetSelectedObjects(hwnd, apidlSelected);
  776. if (SUCCEEDED(hr))
  777. {
  778. // If we have a selection, clone it. Otherwise, we can live with a NULL apidlCache
  779. // (HrSetConnectDisconnectMenuItem and HrEnableOrDisableMenuItems both allow
  780. // NULL pidl arrays
  781. //
  782. if (!apidlSelected.empty())
  783. {
  784. // Clone the pidl array using the cache
  785. //
  786. hr = HrCloneRgIDL(apidlSelected, TRUE, TRUE, apidlCache);
  787. if (FAILED(hr))
  788. {
  789. TraceHr(ttidError, FAL, hr, FALSE, "HrCloneRgIDL failed on apidl in "
  790. "HrOnFolderInitMenuPopup");
  791. }
  792. }
  793. // Only do this for the file menu (iIndex=0)
  794. if (0 == iIndex)
  795. {
  796. // Ignore the return from this, since we want to do both regardless.
  797. // We retrieve this value for debugging purposes only
  798. //
  799. hr = HrSetConnectDisconnectMenuItem(apidlCache, hmenu, idCmdFirst);
  800. if (FAILED(hr))
  801. {
  802. AssertSz(FALSE, "Failed to set the connect/disconnect menu items");
  803. }
  804. }
  805. HrUpdateMenu(hmenu, apidlCache, idCmdFirst);
  806. }
  807. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderInitMenuPopup");
  808. return hr;
  809. }
  810. HRESULT HrOnFolderMergeMenu(IN OUT LPQCMINFO pqcm)
  811. {
  812. HRESULT hr = S_OK;
  813. HMENU hmenu = NULL;
  814. hmenu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(MENU_MERGE_INBOUND_DISCON));
  815. if (hmenu)
  816. {
  817. MergeMenu(_Module.GetResourceInstance(), POPUP_MERGE_FOLDER_CONNECTIONS, MENU_MERGE_INBOUND_DISCON, pqcm);
  818. DestroyMenu(hmenu);
  819. }
  820. TraceHr(ttidShellFolder, FAL, hr, FALSE, "HrOnFolderMergeMenu");
  821. return S_OK;
  822. }
  823. //+---------------------------------------------------------------------------
  824. //
  825. // Function: HrOnFolderGetButtons
  826. //
  827. // Purpose: Folder message handler for defview's DVM_GETBUTTONS
  828. //
  829. // Arguments:
  830. // hwnd [in] Folder window handle
  831. // psf [in] Pointer to the IShellFolder interface
  832. // idCmdFirst [in] Our command ID base
  833. // ptButton [in/out] Button structures to fill
  834. //
  835. // Returns:
  836. //
  837. // Author: jeffspr 15 Dec 1997
  838. //
  839. // Notes:
  840. //
  841. HRESULT HrOnFolderGetButtons(
  842. IN HWND hwnd,
  843. IN LPSHELLFOLDER psf,
  844. IN UINT idCmdFirst,
  845. IN OUT LPTBBUTTON ptButton)
  846. {
  847. HRESULT hr = S_OK;
  848. #if ANY_FREEKIN_THING_IN_TOOLBAR
  849. UINT i = 0;
  850. LRESULT iBtnOffset = 0;
  851. IShellBrowser * psb = FileCabinet_GetIShellBrowser(hwnd);
  852. TBADDBITMAP ab;
  853. PWSTR pszToolbarStrings[2];
  854. for (DWORD dwLoop = 0; dwLoop < c_nToolbarButtons; dwLoop++)
  855. {
  856. // If this isn't a separator, load the text/tip string
  857. //
  858. if (!(c_tbConnections[dwLoop].fsStyle & TBSTYLE_SEP))
  859. {
  860. Assert(c_tbConnections[dwLoop].iString != -1);
  861. pszToolbarStrings[dwLoop] = (PWSTR) SzLoadIds(c_tbConnections[dwLoop].iString);
  862. }
  863. }
  864. // Add the toolbar button bitmap, get it's offset
  865. //
  866. ab.hInst = _Module.GetResourceInstance();
  867. ab.nID = IDB_TB_SMALL; // std bitmaps
  868. hr = psb->SendControlMsg(FCW_TOOLBAR, TB_ADDBITMAP, c_nToolbarButtons,
  869. (LONG_PTR)&ab, &iBtnOffset);
  870. if (SUCCEEDED(hr))
  871. {
  872. for (i = 0; i < c_nToolbarButtons; i++)
  873. {
  874. ptButton[i] = c_tbConnections[i];
  875. if (!(c_tbConnections[i].fsStyle & TBSTYLE_SEP))
  876. {
  877. ptButton[i].idCommand += idCmdFirst;
  878. ptButton[i].iBitmap += (int) iBtnOffset;
  879. ptButton[i].iString = (INT_PTR) pszToolbarStrings[i];
  880. }
  881. }
  882. }
  883. #endif // ANY_FREEKIN_THING_IN_TOOLBAR
  884. // We always want to return success, even if we added nothing.
  885. //
  886. return S_OK;
  887. }
  888. //+---------------------------------------------------------------------------
  889. //
  890. // Function: HrOnFolderGetButtonInfo
  891. //
  892. // Purpose: Folder message handler for defview's DVM_GETBUTTONINFO
  893. //
  894. // Arguments:
  895. // ptbInfo [in/out] Structure that we'll fill in (flags and button
  896. // count)
  897. //
  898. // Returns:
  899. //
  900. // Author: jeffspr 15 Dec 1997
  901. //
  902. // Notes:
  903. //
  904. HRESULT HrOnFolderGetButtonInfo(IN OUT TBINFO * ptbInfo)
  905. {
  906. ptbInfo->uFlags = TBIF_PREPEND;
  907. ptbInfo->cbuttons = c_nToolbarButtons; // size of toolbar array
  908. return S_OK;
  909. }