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.

1657 lines
66 KiB

  1. #ifndef _DEFVIEWP_H_
  2. #define _DEFVIEWP_H_
  3. #include "defview.h"
  4. #include <mshtmhst.h>
  5. #include "urlmon.h"
  6. #include <perhist.h>
  7. #include "inetsmgr.h"
  8. #include <cowsite.h>
  9. #include "ViewState.h"
  10. #include "webvw.h"
  11. #include "runtask.h"
  12. #include "enumuicommand.h"
  13. #include "tlist.h"
  14. // not used in any of our ISF implementations, but needed for legacy ISF implementations
  15. #include "defviewlegacy.h"
  16. class CBackgroundInfoTip; // Used for the background processing of InfoTips
  17. class CDefview;
  18. class CDVDropTarget // dvdt
  19. {
  20. public:
  21. HRESULT DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL ptl, DWORD *pdwEffect);
  22. HRESULT DragOver(DWORD grfKeyState, POINTL ptl, DWORD *pdwEffect);
  23. HRESULT DragLeave();
  24. HRESULT Drop(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  25. void LeaveAndReleaseData();
  26. void ReleaseDataObject();
  27. void ReleaseCurrentDropTarget();
  28. IDataObject * _pdtobj; // from DragEnter()/Drop()
  29. RECT _rcLockWindow; // WindowRect of hwnd for DAD_ENTER
  30. int _itemOver; // item we are visually dragging over
  31. BOOL _fItemOverNotADropTarget; // the item we are currently dragging over was found not to be a drop target
  32. BOOL _fIgnoreSource; // drag is coming from webview / active desktop
  33. IDropTarget * _pdtgtCur; // current drop target, derived from hit testing
  34. DWORD _dwEffectOut; // last *pdwEffect out
  35. DWORD _grfKeyState; // cached key state
  36. POINT _ptLast; // last dragged position
  37. AUTO_SCROLL_DATA _asd; // for auto scrolling
  38. DWORD _dwLastTime; // for auto-opening folders
  39. };
  40. //
  41. // This is a proxy IDropTarget object, which wraps Trident's droptarget.
  42. //
  43. class CHostDropTarget : public IDropTarget
  44. {
  45. public:
  46. // IUnknown
  47. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  48. STDMETHODIMP_(ULONG) AddRef(void) ;
  49. STDMETHODIMP_(ULONG) Release(void);
  50. // IDropTarget
  51. STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  52. STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  53. STDMETHODIMP DragLeave(void);
  54. STDMETHODIMP Drop(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  55. IDropTarget* _pdtFrame; // Drop target of the frame
  56. };
  57. class CSFVSite : public IOleInPlaceSite,
  58. public IOleClientSite,
  59. public IOleDocumentSite,
  60. public IServiceProvider,
  61. public IOleCommandTarget,
  62. public IDocHostUIHandler,
  63. public IOleControlSite,
  64. public IInternetSecurityManager,
  65. public IDispatch //For ambient properties.
  66. {
  67. friend CHostDropTarget;
  68. public:
  69. CSFVSite() { ASSERT(_peds == NULL); }
  70. ~CSFVSite() {
  71. if (_peds) {
  72. _peds->Release();
  73. _peds = NULL;
  74. }
  75. }
  76. // IUnknown
  77. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  78. STDMETHODIMP_(ULONG) AddRef(void) ;
  79. STDMETHODIMP_(ULONG) Release(void);
  80. // IOleWindow
  81. STDMETHODIMP GetWindow(HWND *phwnd);
  82. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  83. // IOleInPlaceSite
  84. STDMETHODIMP CanInPlaceActivate(void);
  85. STDMETHODIMP OnInPlaceActivate(void);
  86. STDMETHODIMP OnUIActivate(void);
  87. STDMETHODIMP GetWindowContext(
  88. IOleInPlaceFrame **ppFrame,
  89. IOleInPlaceUIWindow **ppDoc,
  90. LPRECT lprcPosRect,
  91. LPRECT lprcClipRect,
  92. LPOLEINPLACEFRAMEINFO lpFrameInfo);
  93. STDMETHODIMP Scroll(SIZE scrollExtant);
  94. STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
  95. STDMETHODIMP OnInPlaceDeactivate(void);
  96. STDMETHODIMP DiscardUndoState(void);
  97. STDMETHODIMP DeactivateAndUndo(void);
  98. STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
  99. // IOleClientSite
  100. STDMETHODIMP SaveObject(void);
  101. STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk);
  102. STDMETHODIMP GetContainer(IOleContainer **ppContainer);
  103. STDMETHODIMP ShowObject(void);
  104. STDMETHODIMP OnShowWindow(BOOL fShow);
  105. STDMETHODIMP RequestNewObjectLayout(void);
  106. // IOleDocumentSite
  107. STDMETHODIMP ActivateMe(IOleDocumentView *pviewToActivate);
  108. // IServiceProvider
  109. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppv);
  110. // IOleCommandTarget
  111. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  112. STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  113. // IOleControlSite
  114. STDMETHODIMP OnControlInfoChanged() { return E_NOTIMPL; };
  115. STDMETHODIMP LockInPlaceActive(BOOL fLock) { return E_NOTIMPL; };
  116. STDMETHODIMP GetExtendedControl(IDispatch **ppDisp) { *ppDisp = NULL; return E_NOTIMPL; };
  117. STDMETHODIMP TransformCoords(POINTL *pPtlHimetric, POINTF *pPtfContainer,DWORD dwFlags) { return E_NOTIMPL; };
  118. STDMETHODIMP TranslateAccelerator(MSG *pMsg,DWORD grfModifiers);
  119. STDMETHODIMP OnFocus(BOOL fGotFocus) { return E_NOTIMPL; };
  120. STDMETHODIMP ShowPropertyFrame(void) { return E_NOTIMPL; };
  121. // IDocHostUIHandler
  122. STDMETHODIMP ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved);
  123. STDMETHODIMP GetHostInfo(DOCHOSTUIINFO *pInfo);
  124. STDMETHODIMP ShowUI(DWORD dwID, IOleInPlaceActiveObject *pActiveObject,
  125. IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame,
  126. IOleInPlaceUIWindow *pDoc);
  127. STDMETHODIMP HideUI(void);
  128. STDMETHODIMP UpdateUI(void);
  129. STDMETHODIMP EnableModeless(BOOL fEnable);
  130. STDMETHODIMP OnDocWindowActivate(BOOL fActivate);
  131. STDMETHODIMP OnFrameWindowActivate(BOOL fActivate);
  132. STDMETHODIMP ResizeBorder(
  133. LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow);
  134. STDMETHODIMP TranslateAccelerator(
  135. LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID);
  136. STDMETHODIMP GetOptionKeyPath(BSTR *pbstrKey, DWORD dw);
  137. STDMETHODIMP GetDropTarget(
  138. IDropTarget *pDropTarget, IDropTarget **ppDropTarget);
  139. STDMETHODIMP GetExternal(IDispatch **ppDisp);
  140. STDMETHODIMP TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut);
  141. STDMETHODIMP FilterDataObject(IDataObject *pDO, IDataObject **ppDORet);
  142. // IInternetSecurityManager
  143. STDMETHODIMP SetSecuritySite(IInternetSecurityMgrSite *pSite) { return INET_E_DEFAULT_ACTION; };
  144. STDMETHODIMP GetSecuritySite(IInternetSecurityMgrSite **ppSite) { return INET_E_DEFAULT_ACTION; };
  145. STDMETHODIMP MapUrlToZone(LPCWSTR pwszUrl, DWORD * pdwZone, DWORD dwFlags) { return INET_E_DEFAULT_ACTION; };
  146. STDMETHODIMP GetSecurityId(LPCWSTR pwszUrl, BYTE * pbSecurityId, DWORD * pcbSecurityId, DWORD_PTR dwReserved) { return INET_E_DEFAULT_ACTION; };
  147. STDMETHODIMP ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE * pPolicy, DWORD cbPolicy, BYTE * pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved);
  148. STDMETHODIMP QueryCustomPolicy(LPCWSTR pwszUrl, REFGUID guidKey, BYTE ** ppPolicy, DWORD * pcbPolicy, BYTE * pContext, DWORD cbContext, DWORD dwReserved) { return INET_E_DEFAULT_ACTION; };
  149. STDMETHODIMP SetZoneMapping(DWORD dwZone, LPCWSTR pszPattern, DWORD dwFlags) { return INET_E_DEFAULT_ACTION; };
  150. STDMETHODIMP GetZoneMappings(DWORD dwZone, IEnumString ** ppenumString, DWORD dwFlags) { return INET_E_DEFAULT_ACTION; };
  151. // IDispatch
  152. STDMETHODIMP GetTypeInfoCount(unsigned int *pctinfo)
  153. { return E_NOTIMPL; };
  154. STDMETHODIMP GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo **pptinfo)
  155. { return E_NOTIMPL; };
  156. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, unsigned int cNames, LCID lcid, DISPID *rgdispid)
  157. { return E_NOTIMPL; };
  158. STDMETHODIMP Invoke(DISPID dispidMember, REFIID iid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams,
  159. VARIANT *pvarResult, EXCEPINFO *pexcepinfo,UINT *puArgErr);
  160. CHostDropTarget _dt;
  161. IExpDispSupport * _peds;
  162. };
  163. class CSFVFrame : public IOleInPlaceFrame,
  164. public IAdviseSink,
  165. public IPropertyNotifySink //for READYSTATE
  166. {
  167. public:
  168. enum
  169. {
  170. UNDEFINEDVIEW = -3,
  171. NOEXTVIEW = -2,
  172. HIDEEXTVIEW = -1,
  173. } ;
  174. CSFVFrame() : _fReadyStateComplete(TRUE), _pOleObj(NULL), _bgColor(CLR_INVALID)
  175. {
  176. }
  177. ~CSFVFrame();
  178. // IUnknown
  179. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  180. STDMETHODIMP_(ULONG) AddRef(void) ;
  181. STDMETHODIMP_(ULONG) Release(void);
  182. // IOleWindow
  183. STDMETHODIMP GetWindow(HWND *phwnd);
  184. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  185. // IOleInPlaceUIWindow
  186. STDMETHODIMP GetBorder(LPRECT lprectBorder);
  187. STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS pborderwidths);
  188. STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS pborderwidths);
  189. STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName);
  190. // IOleInPlaceFrame
  191. STDMETHODIMP InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
  192. STDMETHODIMP SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
  193. STDMETHODIMP RemoveMenus(HMENU hmenuShared);
  194. STDMETHODIMP SetStatusText(LPCOLESTR pszStatusText);
  195. STDMETHODIMP EnableModeless(BOOL fEnable);
  196. STDMETHODIMP TranslateAccelerator(LPMSG lpmsg, WORD wID);
  197. // IAdviseSink
  198. STDMETHODIMP_(void) OnDataChange(FORMATETC *, STGMEDIUM *);
  199. STDMETHODIMP_(void) OnViewChange(DWORD dwAspect, LONG lindex);
  200. STDMETHODIMP_(void) OnRename(IMoniker *);
  201. STDMETHODIMP_(void) OnSave();
  202. STDMETHODIMP_(void) OnClose();
  203. // IPropertyNotifySink
  204. STDMETHODIMP OnChanged(DISPID dispid);
  205. STDMETHODIMP OnRequestEdit(DISPID dispid);
  206. private:
  207. friend class CSFVSite;
  208. CSFVSite _cSite;
  209. friend class CDefView;
  210. class CBindStatusCallback : public IBindStatusCallback
  211. , public IServiceProvider
  212. {
  213. friend CSFVFrame;
  214. protected:
  215. // IUnknown
  216. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  217. STDMETHODIMP_(ULONG) AddRef(void) ;
  218. STDMETHODIMP_(ULONG) Release(void);
  219. // IServiceProvider
  220. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppv);
  221. // IBindStatusCallback
  222. STDMETHODIMP OnStartBinding(
  223. DWORD grfBSCOption,
  224. IBinding *pib);
  225. STDMETHODIMP GetPriority(
  226. LONG *pnPriority);
  227. STDMETHODIMP OnLowResource(
  228. DWORD reserved);
  229. STDMETHODIMP OnProgress(
  230. ULONG ulProgress,
  231. ULONG ulProgressMax,
  232. ULONG ulStatusCode,
  233. LPCWSTR szStatusText);
  234. STDMETHODIMP OnStopBinding(
  235. HRESULT hresult,
  236. LPCWSTR szError);
  237. STDMETHODIMP GetBindInfo(
  238. DWORD *grfBINDINFOF,
  239. BINDINFO *pbindinfo);
  240. STDMETHODIMP OnDataAvailable(
  241. DWORD grfBSCF,
  242. DWORD dwSize,
  243. FORMATETC *pformatetc,
  244. STGMEDIUM *pstgmed);
  245. STDMETHODIMP OnObjectAvailable(
  246. REFIID riid,
  247. IUnknown *punk);
  248. };
  249. friend class CBindStatusCallback;
  250. CBindStatusCallback _bsc;
  251. //
  252. // External views stuff
  253. //
  254. // We have DocObject extensions and IShellView extensions
  255. // A (DocObject) extension can
  256. public:
  257. HRESULT InitObj(IUnknown* pObj, LPCITEMIDLIST pidlHere, int iView);
  258. // If we have a moniker, then we are either currently showing it or we are trying to show it.
  259. // (Old code explicitly checked current view and pending view -- this is easier.)
  260. BOOL IsWebView(void) { return _szCurrentWebViewMoniker[0]!=L'\0'; }
  261. HRESULT _HasFocusIO();
  262. HRESULT _UIActivateIO(BOOL fActivate, MSG *pMsg);
  263. HWND GetExtendedViewWindow();
  264. HRESULT SetRect(LPRECT prc);
  265. HRESULT GetCommandTarget(IOleCommandTarget** ppct);
  266. // allow the frame to handle the choice on delegation on translate accelerator...
  267. HRESULT OnTranslateAccelerator(LPMSG pmsg, BOOL* pbTabOffLastTridentStop);
  268. HRESULT _GetHTMLBackgroundColor(COLORREF *pclr); // used in defview.cpp
  269. #ifdef DEBUG
  270. void _ShowWebViewContent();
  271. #endif
  272. private:
  273. COLORREF _bgColor; //Icon text background color for active desktop
  274. UINT _uState:2; // SVUIA_* for _pOleObj (extended view)
  275. IOleObject* _pOleObj;
  276. IOleDocumentView* _pDocView;
  277. IOleInPlaceActiveObject* _pActive;
  278. IViewObject *_pvoActive;
  279. void _CleanUpOleObj(IOleObject* pOleObj);
  280. void _CleanUpOleObjAndDt(IOleObject* pOleObj);
  281. void _CleanupNewOleObj();
  282. void _CleanupOldDocObject(void);
  283. WCHAR _szCurrentWebViewMoniker[MAX_PATH];
  284. HRESULT _GetCurrentWebViewMoniker(LPWSTR wszCurrentMoniker, DWORD cchCurrentMoniker);
  285. HRESULT ShowWebView(LPCWSTR pszMoniker);
  286. HRESULT HideWebView();
  287. HRESULT _CreateNewOleObjFromMoniker(LPCWSTR wszMoniker, IOleObject **ppOleObj);
  288. HRESULT _ShowExtView_Helper(IOleObject* pOleObj);
  289. HRESULT _SwitchToNewOleObj();
  290. HRESULT _GetCurrentZone(IOleObject *pOleObj, VARIANT *pvar);
  291. HRESULT _UpdateZonesStatusPane(IOleObject *pOleObj);
  292. //Fields that store details about the new OLE object while we wait for
  293. //it to reach a READYSTATE_INTERACTIVE.
  294. IOleObject* _pOleObjNew;
  295. BOOL _fSwitchedToNewOleObj;
  296. BOOL _SetupReadyStateNotifyCapability();
  297. BOOL _RemoveReadyStateNotifyCapability();
  298. DWORD _dwConnectionCookie;
  299. BOOL _fReadyStateInteractiveProcessed;
  300. BOOL _fReadyStateComplete;
  301. IOleObject* _pOleObjReadyState;
  302. };
  303. class CCallback
  304. {
  305. public:
  306. CCallback(IShellFolderViewCB* psfvcb) : _psfvcb(psfvcb)
  307. {
  308. if (_psfvcb)
  309. {
  310. _psfvcb->AddRef();
  311. _psfvcb->QueryInterface(IID_PPV_ARG(IFolderFilter, &_psff));
  312. }
  313. }
  314. ~CCallback()
  315. {
  316. ATOMICRELEASE(_psfvcb);
  317. ATOMICRELEASE(_psff);
  318. }
  319. IShellFolderViewCB *GetSFVCB()
  320. {
  321. return _psfvcb;
  322. }
  323. IFolderFilter *GetISFF()
  324. {
  325. return _psff;
  326. }
  327. HRESULT SetCallback(IShellFolderViewCB* pNewCB, IShellFolderViewCB** ppOldCB)
  328. {
  329. // We Release the callback for us, and then AddRef it for the caller who now
  330. // owns the object, which does nothing
  331. *ppOldCB = _psfvcb;
  332. ATOMICRELEASE(_psff);
  333. _psfvcb = pNewCB;
  334. if (pNewCB)
  335. {
  336. pNewCB->AddRef();
  337. pNewCB->QueryInterface(IID_PPV_ARG(IFolderFilter, &_psff));
  338. }
  339. return S_OK;
  340. }
  341. // Default implementation of SFVM_GETVIEWS replacement SFVM_GETVIEWINFOTEMPLATE
  342. HRESULT OnGetWebViewTemplate(DWORD pv, UINT uViewMode, SFVM_WEBVIEW_TEMPLATE_DATA* pvit);
  343. // For legacy SFVM_GETVIEWS implementation:
  344. HRESULT TryLegacyGetViews(SFVM_WEBVIEW_TEMPLATE_DATA* pvit);
  345. HRESULT OnRefreshLegacy(void* pv, BOOL fPrePost);
  346. void _GetExtViews(BOOL bForce);
  347. int GetViewIdFromGUID(SHELLVIEWID const *pvid, SFVVIEWSDATA** ppItem);
  348. CViewsList _lViews;
  349. BOOL _bGotViews;
  350. HRESULT CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
  351. {
  352. HRESULT hr;
  353. if (_psfvcb)
  354. {
  355. hr = _psfvcb->MessageSFVCB(uMsg, wParam, lParam);
  356. // NOTE: if SFVM_GETVIEWDATA is no longer needed, we can nuke this
  357. switch (uMsg)
  358. {
  359. HANDLE_MSG(0, SFVM_REFRESH, OnRefreshLegacy);
  360. }
  361. if (FAILED(hr))
  362. {
  363. switch (uMsg)
  364. {
  365. HANDLE_MSG(0, SFVM_GETWEBVIEW_TEMPLATE, OnGetWebViewTemplate);
  366. }
  367. }
  368. }
  369. else
  370. {
  371. hr = E_NOTIMPL;
  372. }
  373. return hr;
  374. }
  375. BOOL HasCB()
  376. {
  377. return _psfvcb != NULL;
  378. }
  379. private:
  380. IShellFolderViewCB* _psfvcb;
  381. IFolderFilter* _psff;
  382. };
  383. // Variable Column stuff
  384. typedef struct
  385. {
  386. TCHAR szName[MAX_COLUMN_NAME_LEN];
  387. DWORD cChars; // number of characters wide for default
  388. DWORD fmt;
  389. DWORD csFlags; // SHCOLSTATE flags
  390. DWORD tsFlags; // SHTRANSCOLSTATE flags
  391. } COL_INFO;
  392. #define SHTRANSCOLSTATE_TILEVIEWCOLUMN 0x00000001
  393. //Possible values for _iCustomizable
  394. #define YES_CUSTOMIZABLE 1
  395. #define DONTKNOW_IF_CUSTOMIZABLE 0
  396. #define NOT_CUSTOMIZABLE -2
  397. // For communicating with the background property extractor
  398. class CBackgroundDefviewInfo
  399. {
  400. public:
  401. CBackgroundDefviewInfo (LPCITEMIDLIST pidl, UINT uId);
  402. virtual ~CBackgroundDefviewInfo (void);
  403. LPCITEMIDLIST GetPIDL (void) const { return(_pidl); }
  404. UINT GetId() const { return(_uId); }
  405. private:
  406. const LPCITEMIDLIST _pidl;
  407. UINT _uId;
  408. };
  409. class CBackgroundColInfo : public CBackgroundDefviewInfo
  410. {
  411. private:
  412. CBackgroundColInfo (void);
  413. public:
  414. CBackgroundColInfo (LPCITEMIDLIST pidl, UINT uId, UINT uiCol, STRRET& strRet);
  415. ~CBackgroundColInfo (void);
  416. UINT GetColumn (void) const { return(_uiCol); }
  417. LPCTSTR GetText (void) const { return(&_szText[0]); }
  418. private:
  419. const UINT _uiCol;
  420. TCHAR _szText[MAX_COLUMN_NAME_LEN];
  421. };
  422. // The number of "columns" shown in tileview.
  423. // FEATURE:
  424. // We may want to allow this as a registry setting. Or perhaps
  425. // in the desktop.ini. Or perhaps pesisted as per-folder view state?
  426. // Currently, we'll set this two 2 subitems, per spec.
  427. #define TILEVIEWLINES 2
  428. // For communicating with the background file type properties task (for tileview)
  429. class CBackgroundTileInfo : public CBackgroundDefviewInfo
  430. {
  431. private:
  432. CBackgroundTileInfo (void);
  433. public:
  434. CBackgroundTileInfo (LPCITEMIDLIST pidl, UINT uId, UINT rguColumns[], UINT cColumns);
  435. ~CBackgroundTileInfo (void);
  436. UINT* GetColumns (void) { return(_rguColumns); }
  437. UINT GetColumnCount (void)const { return(_cColumns); }
  438. private:
  439. UINT _rguColumns[TILEVIEWLINES];
  440. const UINT _cColumns;
  441. };
  442. class CBackgroundGroupInfo : public CBackgroundDefviewInfo
  443. {
  444. public:
  445. CBackgroundGroupInfo (LPCITEMIDLIST pidl, UINT uId, DWORD dwGroupId);
  446. BOOL VerifyGroupExists(HWND hwnd, ICategorizer* pcat);
  447. DWORD GetGroupId() { return(_dwGroupId); }
  448. private:
  449. DWORD _dwGroupId;
  450. };
  451. // CDefviewEnumTask is defview's IEnumIDList manager.
  452. // This object is used on the UI thread from defview
  453. // and on the task scheduler when it is doing background work.
  454. // All the UI-thread functions are called out as public methods
  455. // during which this object often calls back into CDefView.
  456. //
  457. class CDefviewEnumTask : public CRunnableTask
  458. {
  459. public:
  460. CDefviewEnumTask(CDefView *pdsv);
  461. // IRunnableTask
  462. STDMETHODIMP RunInitRT(void);
  463. STDMETHODIMP InternalResumeRT(void);
  464. // Called from defview from UI thread:
  465. HRESULT FillObjectsToDPA(BOOL fInteractive);
  466. HRESULT FillObjectsDPAToDone();
  467. HRESULT FillObjectsDoneToView();
  468. UINT DPACount() { return _hdpaEnum ? DPA_GetPtrCount(_hdpaEnum) : 0; }
  469. LPCITEMIDLIST* DPAArray() { return _hdpaEnum ? (LPCITEMIDLIST*)DPA_GetPtrPtr(_hdpaEnum) : NULL; }
  470. BOOL _DeleteFromPending(LPCITEMIDLIST pidl);
  471. void _AddToPending(LPCITEMIDLIST pidl);
  472. private:
  473. ~CDefviewEnumTask();
  474. static int CALLBACK _CompareExactCanonical(void *p1, void *p2, LPARAM lParam);
  475. PFNDPACOMPARE _GetCanonicalCompareFunction(void);
  476. LPARAM _GetCanonicalCompareBits();
  477. void _SortForFilter(HDPA hdpa);
  478. void _FilterDPAs(HDPA hdpa, HDPA hdpaOld);
  479. CDefView *_pdsv;
  480. IEnumIDList *_peunk;
  481. HDPA _hdpaEnum;
  482. BOOL _fEnumSorted;
  483. BOOL _fBackground;
  484. HRESULT _hrRet;
  485. HDPA _hdpaPending; // list of refs to SHCNE_CREATEd items while we were enumerating
  486. };
  487. class CDUIView;
  488. #ifdef _X86_
  489. //
  490. // App compat bug 90885.
  491. //
  492. // Hijaak 5.0 grovels through the CDefView class looking for the
  493. // IShellBrowser (whose value it learned from CWM_GETISHELLBROWSER).
  494. // It then assumes that the field right in front of the IShellBrowser
  495. // is the IShellFolder. Unfortunately, since we derive from
  496. // CObjectWithSite and the browser is our site, they accidentally
  497. // find the copy inside CObjectWithSite and then treat CObjectWithSite's
  498. // vtbl as if were an IShellFolder. They then crash, taking the process
  499. // with it. Said process anybody who instantiates a DefView, like Explorer.
  500. // Or anybody who uses a common dialog, which is pretty much everybody.
  501. //
  502. // Here's the dummy IShellFolder-like object we give them.
  503. //
  504. extern const LPVOID c_FakeHijaakFolder;
  505. //
  506. // And here's the class that ensures that the dummy IShellFolder
  507. // comes right before the IShellBrowser. This replaces the
  508. // problematic CObjectWithSite.
  509. //
  510. class CHijaakObjectWithSite : public IObjectWithSite {
  511. public:
  512. //*** IObjectWithSite ***
  513. STDMETHOD(SetSite)(IUnknown *punkSite) {
  514. IUnknown_Set(&_punkSite, punkSite);
  515. return S_OK;
  516. }
  517. STDMETHOD(GetSite)(REFIID riid, void **ppvSite) {
  518. if (_punkSite)
  519. return _punkSite->QueryInterface(riid, ppvSite);
  520. *ppvSite = NULL;
  521. return E_FAIL;
  522. }
  523. CHijaakObjectWithSite() : _psfHijaak(&c_FakeHijaakFolder) { }
  524. ~CHijaakObjectWithSite() {ATOMICRELEASE(_punkSite);}
  525. const LPVOID *_psfHijaak;
  526. IShellBrowser *_psb;
  527. IUnknown *_punkSite;
  528. };
  529. #endif
  530. #define SWITCHTOVIEW_BOTH 0x0
  531. #define SWITCHTOVIEW_NOWEBVIEW 0x1
  532. #define SWITCHTOVIEW_WEBVIEWONLY 0x2
  533. //
  534. // Class definition of CDefView
  535. //
  536. class CDefView : // dsv
  537. public IShellView2,
  538. public IFolderView,
  539. public IShellFolderView,
  540. public IOleCommandTarget, // so psb can talk to extended views
  541. public IDropTarget,
  542. public IViewObject,
  543. public IDefViewFrame, // TODO: remove - currently only used by shell\ext\ftp
  544. public IDefViewFrame3,
  545. public IServiceProvider,
  546. public IDocViewSite,
  547. public IInternetSecurityMgrSite,
  548. public IPersistIDList,
  549. public IDVGetEnum,
  550. #ifdef _X86_
  551. public CHijaakObjectWithSite,
  552. #else
  553. public CObjectWithSite,
  554. #endif
  555. public IContextMenuSite,
  556. public IDefViewSafety,
  557. public IUICommandTarget,
  558. public CWVTASKITEM // webview implementation helper class
  559. {
  560. public:
  561. CDefView(IShellFolder *pshf, IShellFolderViewCB* psfvcb, IShellView* psvOuter);
  562. // IUnknown
  563. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  564. STDMETHODIMP_(ULONG) AddRef(void) ;
  565. STDMETHODIMP_(ULONG) Release(void);
  566. // IShellView
  567. STDMETHODIMP GetWindow(HWND *phwnd);
  568. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  569. STDMETHODIMP EnableModeless(BOOL fEnable);
  570. STDMETHODIMP Refresh();
  571. STDMETHODIMP CreateViewWindow(IShellView *pPrev, LPCFOLDERSETTINGS pfs, IShellBrowser *psb, RECT *prc, HWND *phWnd);
  572. STDMETHODIMP DestroyViewWindow();
  573. STDMETHODIMP UIActivate(UINT uState);
  574. STDMETHODIMP GetCurrentInfo(LPFOLDERSETTINGS lpfs);
  575. STDMETHODIMP TranslateAccelerator(LPMSG pmsg);
  576. STDMETHODIMP AddPropertySheetPages(DWORD dwReserved, LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam);
  577. STDMETHODIMP SaveViewState();
  578. STDMETHODIMP SelectItem(LPCITEMIDLIST pidlItem, UINT uFlags);
  579. STDMETHODIMP GetItemObject(UINT uItem, REFIID riid, void **ppv);
  580. // IShellView2
  581. STDMETHODIMP GetView(SHELLVIEWID* pvid, ULONG uView);
  582. STDMETHODIMP CreateViewWindow2(LPSV2CVW2_PARAMS pParams);
  583. STDMETHODIMP HandleRename(LPCITEMIDLIST pidl);
  584. STDMETHODIMP SelectAndPositionItem(LPCITEMIDLIST pidlItem, UINT uFlags, POINT *ppt);
  585. // IFolderView
  586. STDMETHODIMP GetCurrentViewMode(UINT *pViewMode);
  587. STDMETHODIMP SetCurrentViewMode(UINT ViewMode);
  588. STDMETHODIMP GetFolder(REFIID ridd, void **ppv);
  589. STDMETHODIMP Item(int iItemIndex, LPITEMIDLIST *ppidl);
  590. STDMETHODIMP ItemCount(UINT uFlags, int *pcItems);
  591. STDMETHODIMP Items(UINT uFlags, REFIID riid, void **ppv);
  592. STDMETHODIMP GetSelectionMarkedItem(int *piItem);
  593. STDMETHODIMP GetFocusedItem(int *piItem);
  594. STDMETHODIMP GetItemPosition(LPCITEMIDLIST pidl, POINT* ppt);
  595. STDMETHODIMP GetSpacing(POINT* ppt);
  596. STDMETHODIMP GetDefaultSpacing(POINT* ppt);
  597. STDMETHODIMP GetAutoArrange();
  598. STDMETHODIMP SelectItem(int iItem, DWORD dwFlags);
  599. STDMETHODIMP SelectAndPositionItems(UINT cidl, LPCITEMIDLIST* apidl, POINT* apt, DWORD dwFlags);
  600. // IShellFolderView
  601. STDMETHODIMP Rearrange(LPARAM lParamSort);
  602. STDMETHODIMP GetArrangeParam(LPARAM *plParamSort);
  603. STDMETHODIMP ArrangeGrid();
  604. STDMETHODIMP AutoArrange();
  605. STDMETHODIMP AddObject(LPITEMIDLIST pidl, UINT *puItem);
  606. STDMETHODIMP GetObject(LPITEMIDLIST *ppidl, UINT uItem);
  607. STDMETHODIMP RemoveObject(LPITEMIDLIST pidl, UINT *puItem);
  608. STDMETHODIMP GetObjectCount(UINT *puCount);
  609. STDMETHODIMP SetObjectCount(UINT uCount, UINT dwFlags);
  610. STDMETHODIMP UpdateObject(LPITEMIDLIST pidlOld, LPITEMIDLIST pidlNew, UINT *puItem);
  611. STDMETHODIMP RefreshObject(LPITEMIDLIST pidl, UINT *puItem);
  612. STDMETHODIMP SetRedraw(BOOL bRedraw);
  613. STDMETHODIMP GetSelectedCount(UINT *puSelected);
  614. STDMETHODIMP GetSelectedObjects(LPCITEMIDLIST **pppidl, UINT *puItems);
  615. STDMETHODIMP IsDropOnSource(IDropTarget *pDropTarget);
  616. STDMETHODIMP GetDragPoint(POINT *ppt);
  617. STDMETHODIMP GetDropPoint(POINT *ppt);
  618. STDMETHODIMP MoveIcons(IDataObject *pDataObject);
  619. STDMETHODIMP SetItemPos(LPCITEMIDLIST pidl, POINT *ppt);
  620. STDMETHODIMP IsBkDropTarget(IDropTarget *pDropTarget);
  621. STDMETHODIMP SetClipboard(BOOL bMove);
  622. STDMETHODIMP SetPoints(IDataObject *pDataObject);
  623. STDMETHODIMP GetItemSpacing(ITEMSPACING *pSpacing);
  624. STDMETHODIMP SetCallback(IShellFolderViewCB* pNewCB, IShellFolderViewCB** ppOldCB);
  625. STDMETHODIMP Select(UINT dwFlags);
  626. STDMETHODIMP QuerySupport(UINT * pdwSupport);
  627. STDMETHODIMP SetAutomationObject(IDispatch *pdisp);
  628. // IOleCommandTarget
  629. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  630. STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  631. // IDropTarget
  632. STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL ptl, DWORD *pdwEffect)
  633. { return _dvdt.DragEnter(pdtobj, grfKeyState, ptl, pdwEffect); }
  634. STDMETHODIMP DragOver(DWORD grfKeyState, POINTL ptl, DWORD *pdwEffect)
  635. { return _dvdt.DragOver(grfKeyState, ptl, pdwEffect); }
  636. STDMETHODIMP DragLeave()
  637. { return _dvdt.DragLeave(); }
  638. STDMETHODIMP Drop(IDataObject *pdtobj,
  639. DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
  640. { return _dvdt.Drop(pdtobj, grfKeyState, pt, pdwEffect); }
  641. // IViewObject
  642. STDMETHODIMP Draw(DWORD, LONG, void *, DVTARGETDEVICE *, HDC, HDC,
  643. const RECTL *, const RECTL *, int (*)(ULONG_PTR), ULONG_PTR);
  644. STDMETHODIMP GetColorSet(DWORD, LONG, void *, DVTARGETDEVICE *, HDC,
  645. LOGPALETTE **);
  646. STDMETHODIMP Freeze(DWORD, LONG, void *, DWORD *);
  647. STDMETHODIMP Unfreeze(DWORD);
  648. STDMETHODIMP SetAdvise(DWORD, DWORD, IAdviseSink *);
  649. STDMETHODIMP GetAdvise(DWORD *, DWORD *, IAdviseSink **);
  650. // IDefViewFrame
  651. STDMETHODIMP GetShellFolder(IShellFolder **ppsf);
  652. // IDefViewFrame3
  653. STDMETHODIMP GetWindowLV(HWND * phwnd);
  654. STDMETHODIMP OnResizeListView();
  655. STDMETHODIMP ShowHideListView();
  656. STDMETHODIMP ReleaseWindowLV(void);
  657. STDMETHODIMP DoRename();
  658. // IContextMenuSite
  659. STDMETHODIMP DoContextMenuPopup(IUnknown* punkCM, UINT fFlags, POINT pt);
  660. // IPersist
  661. STDMETHODIMP GetClassID(LPCLSID lpClassID) {return E_NOTIMPL;}
  662. // IPersistIDList
  663. STDMETHODIMP SetIDList(LPCITEMIDLIST pidl) {return E_NOTIMPL;}
  664. STDMETHODIMP GetIDList(LPITEMIDLIST *ppidl) { *ppidl = _GetViewPidl(); return *ppidl ? S_OK : E_FAIL;}
  665. // IServiceProvider
  666. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppv);
  667. // IDocViewSite
  668. STDMETHODIMP OnSetTitle(VARIANTARG *pvTitle);
  669. // IDVGetEnum
  670. STDMETHODIMP SetEnumReadyCallback(PFDVENUMREADYBALLBACK pfn, void *pvData);
  671. STDMETHODIMP CreateEnumIDListFromContents(LPCITEMIDLIST pidlFolder, DWORD dwEnumFlags, IEnumIDList **ppenum);
  672. // IDefViewSafety
  673. STDMETHODIMP IsSafePage();
  674. // IUICommandTarget
  675. STDMETHODIMP get_Name(REFGUID guidCanonicalName, IShellItemArray *psiItemArray, LPWSTR *ppszName);
  676. STDMETHODIMP get_Icon(REFGUID guidCanonicalName, IShellItemArray *psiItemArray, LPWSTR *ppszIcon);
  677. STDMETHODIMP get_Tooltip(REFGUID guidCanonicalName, IShellItemArray *psiItemArray, LPWSTR *ppszInfotip);
  678. STDMETHODIMP get_State(REFGUID guidCanonicalName, IShellItemArray *psiItemArray, UISTATE* puisState);
  679. STDMETHODIMP Invoke(REFGUID guidCanonicalName, IShellItemArray *psiItemArray, IBindCtx *pbc);
  680. // Helper functions for IUICommandTarget implementation:
  681. IShellItemArray *_CreateSelectionShellItemArray(void);
  682. IShellItemArray* _GetFolderAsShellItemArray();
  683. HRESULT _CheckAttribs(IShellItemArray *psiItemArray, DWORD dwAttribMask, DWORD dwAttribValue, UISTATE* puisState);
  684. HRESULT _GetFullPathNameAt(IShellItemArray *psiItemArray,DWORD dwIndex,LPOLESTR *pszPath);
  685. static HRESULT _CanWrite(IUnknown* pv,IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  686. static HRESULT _CanRename(IUnknown* pv,IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  687. static HRESULT _CanMove(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  688. static HRESULT _CanCopy(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  689. static HRESULT _CanPublish(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  690. static HRESULT _CanShare(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  691. static HRESULT _CanEmail(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  692. static BOOL _DoesStaticMenuHaveVerb(IShellItemArray *psiItemArray, LPCWSTR pszVerb);
  693. static HRESULT _CanPrint(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  694. static HRESULT _HasPrintVerb(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  695. static HRESULT _CanDelete(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  696. BOOL _IsSystemDrive(void);
  697. static HRESULT _CanViewDrives(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  698. static HRESULT _CanHideDrives(IUnknown* pv,IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  699. static HRESULT _CanViewFolder(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  700. static HRESULT _CanHideFolder(IUnknown* pv, IShellItemArray *psiItemArray, BOOL fOkToBeSlow, UISTATE* puisState);
  701. HRESULT _DoVerb(IShellItemArray *psiItemArray, LPCSTR pszVerbA);
  702. HRESULT _DoDropOnClsid(REFCLSID clsidDrop,IDataObject* pdo);
  703. static HRESULT _OnNewFolder(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  704. static HRESULT _OnRename(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  705. static HRESULT _OnMove(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  706. static HRESULT _OnCopy(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  707. static HRESULT _OnPublish(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  708. static HRESULT _OnShare(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  709. static HRESULT _OnEmail(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  710. static HRESULT _OnPrint(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  711. static HRESULT _OnDelete(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  712. HRESULT RemoveBarricade (void);
  713. static HRESULT _OnView(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  714. static HRESULT _OnHide(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  715. static HRESULT _OnAddRemovePrograms(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  716. static HRESULT _OnSearchFiles(IUnknown* pv, IShellItemArray *psiItemArray, IBindCtx *pbc);
  717. const WVTASKITEM* _FindTaskItem(REFGUID guidCanonicalName);
  718. DWORD _DefaultColumnState(UINT iCol);
  719. BOOL _IsColumnHidden(UINT iCol);
  720. BOOL _IsColumnInListView(UINT iCol);
  721. BOOL _IsDetailsColumn(UINT iCol);
  722. BOOL _IsTileViewColumn(UINT iCol);
  723. HRESULT AddColumnsToMenu(HMENU hm, DWORD dwBase);
  724. UINT _RealToVisibleCol(UINT uRealCol);
  725. UINT _VisibleToRealCol(UINT uVisCol);
  726. // handle messages
  727. LRESULT _OnCreate(HWND hWnd);
  728. LRESULT _OnNotify(NMHDR *pnm);
  729. LRESULT _TBNotify(NMHDR *pnm);
  730. LRESULT _OnLVNotify(NM_LISTVIEW *plvn);
  731. LRESULT _OnBeginDrag(NM_LISTVIEW *pnm);
  732. int _FindItem(LPCITEMIDLIST pidl, LPITEMIDLIST *ppidlFound, BOOL fSamePtr, BOOL fForwards = TRUE);
  733. int _FindItemHint(LPCITEMIDLIST pidl, int iItem);
  734. int _FindGroupItem(LPITEMIDLIST pidl);
  735. int _UpdateObject(LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew);
  736. void _AddOrUpdateItem(LPCITEMIDLIST pidlOld, LPITEMIDLIST pidlNew);
  737. int _RefreshObject(LPITEMIDLIST *ppidl);
  738. int _RemoveObject(LPCITEMIDLIST pidl, BOOL fSamePtr);
  739. BOOL _GetItemPosition(LPCITEMIDLIST pidl, POINT *ppt);
  740. BOOL _IsPositionedView();
  741. void _OnGetInfoTip(NMLVGETINFOTIP *plvn);
  742. void _OnRename(LPCITEMIDLIST* ppidl);
  743. LPITEMIDLIST _ObjectExists(LPCITEMIDLIST pidl, BOOL fGlobal);
  744. UINT _GetExplorerFlag();
  745. // private stuff
  746. void PropagateOnViewChange(DWORD dwAspect, LONG lindex);
  747. void PropagateOnClose();
  748. BOOL OnActivate(UINT uState);
  749. BOOL OnDeactivate();
  750. BOOL HasCurrentViewWindowFocus();
  751. HWND ViewWindowSetFocus();
  752. void _OnWinIniChange(WPARAM wParam, LPCTSTR pszSection);
  753. void _OnWinIniChangeDesktop(WPARAM wParam, LPCTSTR pszSection);
  754. void _SetFolderColors();
  755. DWORD _LVStyleFromView();
  756. DWORD _LVExStyleFromView();
  757. UINT _UxGetView();
  758. BOOL _IsReportView();
  759. BOOL _GetColorsFromHTMLdoc(COLORREF *clrTextBk, COLORREF *clrHotlight);
  760. void _SetFocus();
  761. void _UpdateUnderlines();
  762. void _SetSysImageList();
  763. void _SetTileview();
  764. void _BestFit();
  765. UINT _ValidateViewMode(UINT uViewMode);
  766. UINT _GetDefaultViewMode();
  767. void _GetDeferredViewSettings(UINT* puViewMode);
  768. HRESULT _SelectAndPosition(int iItem, UINT uFlags, POINT *ppt);
  769. HRESULT _Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  770. inline BOOL _IsOwnerData();
  771. BOOL _IsDesktop();
  772. inline BOOL _IsCommonDialog();
  773. BOOL _IsListviewVisible();
  774. HRESULT _IncludeObject(LPCITEMIDLIST pidl);
  775. HRESULT _OnDefaultCommand();
  776. HRESULT _OnStateChange(UINT code);
  777. int _AddObject(LPITEMIDLIST pidl);
  778. void _UpdateImage(int iImage);
  779. void _DismissEdit();
  780. void _OnInitMenu();
  781. HRESULT _ForwardMenuMessages(DWORD dwID, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult, BOOL* pfHandled);
  782. void _RemoveThumbviewTasks();
  783. HRESULT _AddTask(IRunnableTask *pTask, REFTASKOWNERID rTID, DWORD_PTR lParam, DWORD dwPriority, DWORD grfFlags);
  784. HRESULT _ExplorerCommand(UINT idFCIDM);
  785. LRESULT _OnMenuSelect(UINT id, UINT mf, HMENU hmenu);
  786. HRESULT _AutoAutoArrange(DWORD dwReserved);
  787. // Infotip Methods (public)
  788. //
  789. HRESULT PreCreateInfotip(HWND hwndContaining, UINT_PTR uToolID, LPRECT prectTool); // ui thread
  790. HRESULT PostCreateInfotip(HWND hwndContaining, UINT_PTR uToolID, HINSTANCE hinst, UINT_PTR uInfotipID, LPARAM lParam); // bg thread
  791. HRESULT PostCreateInfotip(HWND hwndContaining, UINT_PTR uToolID, LPCWSTR pwszInfotip, LPARAM lParam); // bg thread
  792. HRESULT CreateInfotip(HWND hwndContaining, UINT_PTR uToolID, LPRECT prectTool, HINSTANCE hinst, UINT_PTR uInfotipID, LPARAM lParam);// ui thread
  793. HRESULT CreateInfotip(HWND hwndContaining, UINT_PTR uToolID, LPRECT prectTool, LPCWSTR pwszInfotip, LPARAM lParam); // ui thread
  794. HRESULT DestroyInfotip(HWND hwndContaining, UINT_PTR uToolID); // ui thread
  795. HRESULT RepositionInfotip(HWND hwndContaining, UINT_PTR uToolID, LPRECT prectTool); // ui thread
  796. HRESULT RelayInfotipMessage(HWND hwndFrom, UINT uMsg, WPARAM wParam, LPARAM lParam); // ui thread
  797. // Menu Methods (public)
  798. //
  799. void RecreateMenus();
  800. void InitViewMenu(HMENU hmInit);
  801. // Toolbar Methods (public)
  802. //
  803. void EnableToolbarButton(UINT uiCmd, BOOL bEnable);
  804. HRESULT _GetPropertyUI(IPropertyUI **pppui);
  805. int CheckCurrentViewMenuItem(HMENU hmenu);
  806. void CheckToolbar();
  807. void OnListViewDelete(int iItem, LPITEMIDLIST pidl, BOOL fCallCB);
  808. void HandleKeyDown(LV_KEYDOWN *lpnmhdr);
  809. void AddColumns();
  810. void _ShowControl(UINT uControl, int idCmd);
  811. LRESULT _OnInitMenuPopup(HMENU hmInit, int nIndex, BOOL fSystemMenu);
  812. void _SetUpMenus(UINT uState);
  813. void SelectPendingSelectedItems();
  814. inline BOOL _ItemsDeferred();
  815. void _ClearPendingSelectedItems();
  816. void AddCopyHook();
  817. int FindCopyHook(BOOL fRemoveInvalid);
  818. void RemoveCopyHook();
  819. private:
  820. HRESULT _DoContextMenuPopup(IUnknown* punkCM, UINT fFlags, POINT pt, BOOL fListviewItem);
  821. public:
  822. void ContextMenu(DWORD dwPos);
  823. LPITEMIDLIST _GetViewPidl(); // return copy of pidl of folder we're viewing
  824. BOOL _IsViewDesktop();
  825. BOOL _GetPath(LPTSTR pszPath);
  826. HRESULT _GetNameAndFlags(UINT gdnFlags, LPTSTR psz, UINT cch, DWORD *pdwFlags);
  827. BOOL _CachedIsCustomizable();
  828. LRESULT _OnDefviewEditCommand(UINT uID);
  829. HRESULT _DoMoveOrCopyTo(REFCLSID clsid,IShellItemArray *psiItemArray);
  830. void _OnSetWebView(BOOL fOn);
  831. LRESULT _OnCommand(IContextMenu *pcmSel, WPARAM wParam, LPARAM lParam);
  832. BOOL _OnAppCommand(UINT cmd, UINT uDevice, DWORD dwKeys);
  833. LRESULT WndSize(HWND hWnd);
  834. void FillDone();
  835. void OnLVSelectionChange(NM_LISTVIEW *plvn);
  836. void _OnLVSelectionChange(int iItem, UINT uOldState, UINT uNewState, LPARAM lParam);
  837. void RegisterSFVEvents(IUnknown * pTarget, BOOL fConnect);
  838. HRESULT FillObjectsShowHide(BOOL fInteractive);
  839. HRESULT _GetDetailsHelper(int i, DETAILSINFO *pdi);
  840. HRESULT CallCB(UINT uMsg, WPARAM wParam, LPARAM lParam);
  841. BOOL HasCB()
  842. {
  843. return _cCallback.HasCB();
  844. }
  845. HRESULT _FireEvent(DISPID dispid);
  846. void _CallRefresh(BOOL fPreRefresh);
  847. void _PostSelectionChangedMessage(UINT);
  848. void _OnSelectionChanged();
  849. void _OnDelayedSelectionChange();
  850. void _PostNoItemStateChangedMessage();
  851. void _OnNoItemStateChanged();
  852. void _PostEnumDoneMessage();
  853. void _PostFillDoneMessage();
  854. void _OnEnumDoneMessage();
  855. void _OnContentsChanged();
  856. void _OnDelayedContentsChanged();
  857. void _FixupColumnsForTileview(UINT *rguColumns, UINT cColumns);
  858. HRESULT _PeekColumnsCache(PTSTR pszPath, LPCITEMIDLIST pidl, UINT rguColumns[], UINT *pcColumns);
  859. HRESULT _GetImportantColumns(LPCITEMIDLIST pidl, UINT rguColumns[], UINT *pcColumns);
  860. void _SetImportantColumns(CBackgroundTileInfo *pDVTileInfo);
  861. void _SetView(UINT fvm);
  862. HRESULT _ReloadListviewContent();
  863. HRESULT _ReloadContent(BOOL fForce = FALSE);
  864. BOOL _IsImageMode(UINT fvm)
  865. {return (fvm == FVM_THUMBNAIL) || (fvm == FVM_THUMBSTRIP); }
  866. BOOL _IsImageMode()
  867. {return (_fs.ViewMode == FVM_THUMBNAIL) || (_fs.ViewMode == FVM_THUMBSTRIP); }
  868. BOOL _IsTileMode(UINT fvm)
  869. { return (fvm == FVM_TILE); }
  870. inline BOOL _IsTileMode()
  871. { return (_fs.ViewMode == FVM_TILE); }
  872. BOOL _IsAutoArrange()
  873. { return ((_fs.fFlags & FWF_AUTOARRANGE) || (_fs.ViewMode == FVM_THUMBSTRIP)); }
  874. HRESULT _GetWebViewMoniker(LPWSTR pszMoniker, DWORD cchMoniker);
  875. HRESULT _SwitchToWebView(BOOL bShow);
  876. HRESULT _GetDefaultWebviewContent(BOOL bForFileFolderTasks);
  877. void _FreeWebViewContentData();
  878. BOOL _QueryBarricadeState();
  879. HRESULT _TryShowWebView(UINT fvmNew, UINT fvmOld);
  880. HRESULT _TryHideWebView();
  881. HRESULT _SwitchToViewFVM(UINT fvmNew, UINT uiType = SWITCHTOVIEW_BOTH);
  882. void _ShowThemeWatermark();
  883. void _ShowLegacyWatermark();
  884. void _SetThemeWatermark();
  885. void _SetLegacyWatermark(LPCTSTR pszLegacyWatermark);
  886. void _UpdateListviewColors();
  887. LRESULT _SwitchDesktopHTML(BOOL fShow);
  888. void InitSelectionMode();
  889. void _UpdateSelectionMode();
  890. void _OnMoveWindowToTop(HWND hwnd);
  891. HWND GetChildViewWindow();
  892. BOOL _InvokeCustomization();
  893. HRESULT _OnViewWindowActive();
  894. void _UpdateRegFlags();
  895. void _DoColumnsMenu(int x, int y);
  896. BOOL _HandleColumnToggle(UINT uCol, BOOL bRefresh);
  897. void _AddColumnToListView(UINT uCol, UINT uColVis);
  898. void _SameViewMoveIcons();
  899. void _MoveSelectedItems(int dx, int dy, BOOL fAbsolute);
  900. void _AddTileColumn(UINT uCol);
  901. void _RemoveTileColumns();
  902. void _ResetTileInfo(UINT uColVis, BOOL bAdded);
  903. void _RemoveTileInfo();
  904. HRESULT _GetIPersistHistoryObject(IPersistHistory **ppph);
  905. HRESULT _GetStorageStream(DWORD grfMode, IStream* *ppIStream);
  906. HRESULT _SaveGlobalViewState(void);
  907. HRESULT _LoadGlobalViewState(IStream* *ppIStream);
  908. HRESULT _ResetGlobalViewState(void);
  909. LPCITEMIDLIST _GetPIDL(int i);
  910. LPCITEMIDLIST _GetPIDLParam(LPARAM lParam, int i);
  911. int _HitTest(const POINT *ppt, BOOL fIgnoreEdge = FALSE);
  912. void _AlterEffect(DWORD grfKeyState, DWORD *pdwEffect, UINT uFlags);
  913. BOOL _IsDropOnSource(IDropTarget *pdtgt);
  914. BOOL _IsBkDropTarget(IDropTarget *pdtgt);
  915. BOOL _GetDropPoint(POINT *ppt);
  916. BOOL _GetInsertPoint(POINT *ppt);
  917. BOOL _GetDragPoint(POINT *ppt);
  918. void _GetToolTipText(UINT_PTR id, LPTSTR pszText, UINT cchText);
  919. void _GetCBText(UINT_PTR id, UINT uMsgT, UINT uMsgA, UINT uMsgW, LPTSTR psz, UINT cch);
  920. void _GetMenuHelpText(UINT_PTR id, LPTSTR pszText, UINT cchText);
  921. void _SetItemPos(LPSFV_SETITEMPOS psip);
  922. void _FullViewUpdate(BOOL fUpdateItem);
  923. void _UpdateEnumerationFlags();
  924. void _SetItemPosition(int i, int x, int y);
  925. void _GlobeAnimation(BOOL fStartSpinning, BOOL fForceStop = FALSE);
  926. void _PaintErrMsg(HWND hWnd);
  927. void _SetPoints(UINT cidl, LPCITEMIDLIST *apidl, IDataObject *pdtobj);
  928. BOOL _GetItemSpacing(ITEMSPACING *pis);
  929. LRESULT _OnSetClipboard(BOOL bMove);
  930. LRESULT _OnClipboardChange();
  931. void _RestoreAllGhostedFileView();
  932. BOOL _ShouldShowWebView();
  933. void _ShowViewEarly();
  934. BOOL _SetupNotifyData();
  935. DWORD _GetEnumFlags();
  936. // Arrange
  937. BOOL _InitArrangeMenu(HMENU hmenuCtx);
  938. BOOL _ArrangeBy(UINT idCmd);
  939. BOOL _InitExtendedGroups(ICategoryProvider* pcp, HMENU hmenuCtx, int iIndex, int* piIdToCheck);
  940. // Grouping
  941. void _ToggleGrouping();
  942. void _GroupBy(int iColumn);
  943. BOOL _IsSlowGroup(const GUID *pguid);
  944. BOOL _CategorizeOnGUID(const GUID* pguid, const SHCOLUMNID* pscid);
  945. BOOL _CategorizeOnSCID(const SHCOLUMNID* pscid);
  946. void _OnCategoryTaskAdd();
  947. void _OnCategoryTaskDone();
  948. DWORD _GetGroupForItem(int iItem, LPCITEMIDLIST pidl);
  949. BOOL _LoadCategory(GUID *pguidGroupID);
  950. HRESULT _OnRearrange(LPARAM lParamSort, BOOL fAllowToggle);
  951. // Thumbnail Support
  952. HRESULT ExtractItem(UINT *puIndex, int iItem, LPCITEMIDLIST pidl, BOOL fBackground, BOOL fForce, DWORD dwMaxPriority);
  953. DWORD _GetOverlayMask(LPCITEMIDLIST pidl);
  954. HRESULT UpdateImageForItem(DWORD dwTaskID, HBITMAP hImage, int iItem, LPCITEMIDLIST pidl,
  955. LPCWSTR pszPath, FILETIME ftDateStamp, BOOL fCache, DWORD dwPriority);
  956. HRESULT _SafeAddImage(BOOL fQuick, IMAGECACHEINFO* prgInfo, UINT* piImageIndex, int iListID);
  957. HRESULT TaskUpdateItem(LPCITEMIDLIST pidl, int iItem, DWORD dwMask, LPCWSTR pszPath,
  958. FILETIME ftDateStamp, int iThumbnail, HBITMAP hBmp, DWORD dwItemID);
  959. void _UpdateThumbnail(int iItem, int iImage, LPCITEMIDLIST pidl);
  960. void _CleanupUpdateThumbnail(DSV_UPDATETHUMBNAIL* putn);
  961. COLORREF _GetBackColor();
  962. void _CacheDefaultThumbnail(LPCITEMIDLIST pidl, int* piIcon);
  963. HRESULT _CreateOverlayThumbnail(int iIndex, HBITMAP* phbmOverlay, HBITMAP* phbmMask);
  964. int _MapIndexPIDLToID(int iIndex, LPCITEMIDLIST pidl);
  965. int _MapIDToIndex(int iID);
  966. void _ThumbnailMapInit();
  967. void _ThumbnailMapClear();
  968. void _SetThumbview();
  969. void _ResetThumbview();
  970. void _GetThumbnailSize(SIZE *psize);
  971. BOOL _IsUsingFullIconSelection();
  972. int _IncrementWriteTaskCount();
  973. int _DecrementWriteTaskCount();
  974. HRESULT CreateDefaultThumbnail(int iIndex, HBITMAP * phBmpThumbnail, BOOL fCorner);
  975. int ViewGetIconIndex(LPCITEMIDLIST pidl);
  976. ULONG _ApproxItemsPerView();
  977. void _DoThumbnailReadAhead();
  978. HRESULT _GetDefaultTypeExtractor(LPCITEMIDLIST pidl, IExtractImage **ppExt);
  979. DWORD _Attributes(LPCITEMIDLIST pidl, DWORD dwAttribs);
  980. HRESULT _EnumThings(UINT uWhat, IEnumIDList **ppenum);
  981. void _ClearPostedMsgs(HWND hwnd);
  982. HDPA _dpaThumbnailMap;
  983. IShellImageStore* _pDiskCache;
  984. IImageCache3* _pImageCache;
  985. DWORD _dwRecClrDepth;
  986. int _iMaxCacheSize;
  987. int _iWriteTaskCount;
  988. SIZE _sizeThumbnail;
  989. HPALETTE _hpalOld;
  990. COLORREF _rgbBackColor;
  991. ULONG_PTR _tokenGdiplus;
  992. HRESULT _GetBrowserPalette(HPALETTE* phpal);
  993. LONG _cRef;
  994. CDVDropTarget _dvdt;
  995. CViewState _vs;
  996. IShellView *_psvOuter; // May be NULL
  997. IShellFolder *_pshf;
  998. IShellFolder2 *_pshf2;
  999. IShellFolder *_pshfParent;
  1000. IShellFolder2 *_pshf2Parent;
  1001. LPITEMIDLIST _pidlRelative;
  1002. LPITEMIDLIST _pidlSelectAndPosition;
  1003. UINT _uSelectAndPositionFlags;
  1004. #ifndef _X86_
  1005. // In the _X86_ case, the _psb is inside the CHijaakObjectWithSite
  1006. IShellBrowser *_psb;
  1007. #endif
  1008. ICommDlgBrowser *_pcdb; // extended ICommDlgBrowser
  1009. FOLDERSETTINGS _fs;
  1010. IContextMenu *_pcmSel; // pcm for selected objects.
  1011. IContextMenu *_pcmFile; // this is for the File menu only (you can't re-use a contextmenu once QueryContextMenu has been called)
  1012. IContextMenu *_pcmContextMenuPopup; // pcm for TrackPopupMenu usage
  1013. IShellItemArray *_pSelectionShellItemArray; // selection object for the current selection
  1014. IShellItemArray *_pFolderShellItemArray; // shellItemArray for this folder.
  1015. IShellIcon *_psi; // for getting icon fast
  1016. IShellIconOverlay *_psio; // For getting iconOverlay fast
  1017. CLSID _clsid; // the clsid of this pshf;
  1018. ICategorizer* _pcat;
  1019. HDSA _hdaCategories;
  1020. int _iLastFoundCat;
  1021. int _iIncrementCat;
  1022. HWND _hwndMain;
  1023. HWND _hwndView;
  1024. HWND _hwndListview;
  1025. HWND _hwndInfotip; // infotip control
  1026. HWND _hwndStatic;
  1027. HACCEL _hAccel;
  1028. int _fmt;
  1029. UINT _uState; // SVUIA_*
  1030. HMENU _hmenuCur;
  1031. ULONG _uRegister;
  1032. POINT _ptDrop;
  1033. POINT _ptDragAnchor; // start of the drag
  1034. int _itemCur; // The current item in the drop target
  1035. IDropTarget *_pdtgtBack; // of the background (shell folder)
  1036. IShellDetails *_psd;
  1037. UINT _cxChar;
  1038. LPCITEMIDLIST _pidlMonitor;
  1039. LONG _lFSEvents;
  1040. TBBUTTON* _pbtn;
  1041. int _cButtons; // count of buttons that are showing by default
  1042. int _cTotalButtons; // count of buttons including those hidden by default
  1043. IShellTaskScheduler2 *_pScheduler;
  1044. CDUIView *_pDUIView;
  1045. BITBOOL _fSlowGroup:1;
  1046. BITBOOL _fInBackgroundGrouping: 1;
  1047. BITBOOL _bDragSource:1;
  1048. BITBOOL _bDropAnchor:1;
  1049. BITBOOL _fUserPositionedItems:1;
  1050. BITBOOL _bHaveCutStuff:1;
  1051. BITBOOL _bClipViewer:1;
  1052. BITBOOL _fShowAllObjects:1;
  1053. BITBOOL _fInLabelEdit:1;
  1054. BITBOOL _fDisabled:1;
  1055. BITBOOL _bBkFilling:1;
  1056. BITBOOL _bContextMenuMode:1;
  1057. BITBOOL _bMouseMenu:1;
  1058. BITBOOL _fHasDeskWallPaper:1;
  1059. BITBOOL _fShowCompColor:1;
  1060. BITBOOL _bRegisteredDragDrop:1;
  1061. BITBOOL _fEnumFailed:1; // TRUE if enum failed.
  1062. BITBOOL _fGetWindowLV:1; // DVOC has grabbed the listview (it set the owner, repositioned it)
  1063. BITBOOL _fClassic:1; // SSF_WIN95CLASSIC setting/restriction
  1064. BITBOOL _fCombinedView:1; // Implies a regional listview layered on top of an extended view (the desktop with AD on)
  1065. BITBOOL _fCycleFocus:1; // 1=got callback to do CycleFocus
  1066. BITBOOL _fSelectionChangePending:1;
  1067. BITBOOL _fNoItemStateChangePending:1;
  1068. BITBOOL _fCanActivateNow:1; // FALSE from creation until we can be activated, TRUE implies we can SHDVID_CANACTIVATENOW
  1069. BITBOOL _fWin95ViewState:1; // TRUE iff Advanced option set to Win95 behavior
  1070. BITBOOL _fDesktopModal:1; // TRUE iff desktop is in modal state.
  1071. BITBOOL _fDesktopRefreshPending:1; // TRUE iff a refresh of desktop was prevented because of modal state.
  1072. BITBOOL _fRefreshBuffered:1; // TRUE iff a buffered refresh is pending!
  1073. BITBOOL _fHasListViewFocus:1;
  1074. BITBOOL _bLoadedColumns:1; // TRUE after we've loaded cols from the savestream. (after we're switched to details)
  1075. BITBOOL _fIsAsyncDefView:1; // TRUE if Defview is Asynchronous
  1076. // Combined view colors that can be specified via registry or desktop.ini
  1077. BITBOOL _bAutoSelChangeTimerSet:1; // indicates if the timer to send the sel change notification to the automation obj is set
  1078. BITBOOL _fDestroying:1; // DestroyViewWindow was called
  1079. BITBOOL _fIgnoreItemChanged: 1;
  1080. BITBOOL _fReadAhead: 1;
  1081. BITBOOL _fGroupView: 1;
  1082. BITBOOL _fActivateLV: 1; // Indicates that we have to activate the
  1083. // listview rather than defview (the webview case)
  1084. BITBOOL _fAllowSearchingWindow: 1; // use "searching" window, used for user-initiated enum (and first enum)
  1085. BITBOOL _fSyncOnFillDone: 1; // set when _vs is valid for us to re-sync position information
  1086. BITBOOL _fListViewShown: 1; // TRUE iff _hwndListview is shown
  1087. BITBOOL _fListviewRedraw: 1; // TRUE iff WM_REDRAW(FALSE) on _hwndListview, for listview hack work-around
  1088. BITBOOL _fQueryWebViewData: 1; // TRUE iff SFVM_WEBVIEW_CONTENT_DATA has been queried
  1089. BITBOOL _fGlobeCanSpin:1; // Spinning globe implies navigation, only allow it to spin when the view is first created
  1090. BITBOOL _fPositionRecycleBin:1; // TRUE iff desktop AND clean install.
  1091. BITBOOL _fScrolling:1; // We are currently scrolling
  1092. BITBOOL _fRequestedTileDuringScroll:1; // Indicates we request tile column information while scrolling
  1093. BITBOOL _fSetTileViewSortedCol:1; // Indicates we have set the tileview sorted column
  1094. BITBOOL _fBackgroundStatusTextValid:1; // Is the background statusbar text still valid.
  1095. BITBOOL _fUserRejectedWebViewTemplate:1;
  1096. DWORD _crefGlobeSpin; // so the different components that want to keep the globe spinning can reference count it
  1097. DWORD _crefSearchWindow; // so the different components that want to keep the "searching" window up can reference count it
  1098. COLORREF _crCustomColors[CRID_COLORCOUNT];
  1099. UINT _idThemeWatermark;
  1100. LPTSTR _pszLegacyWatermark;
  1101. // for single click activation
  1102. DWORD _dwSelectionMode;
  1103. HWND _hwndNextViewer;
  1104. LRESULT _iStdBMOffset;
  1105. LRESULT _iViewBMOffset;
  1106. CCallback _cCallback; // Optional client callback
  1107. HDSA _hdsaSelect; // List of items that are selected.
  1108. HDSA _hdsaSCIDCache; // Cache the SCIDs so we can map SCID to column# (tileview)
  1109. int _iLastFind;
  1110. UINT _uDefToolbar;
  1111. CSFVFrame _cFrame;
  1112. ULONG _uCachedSelAttrs;
  1113. UINT _uCachedSelCount;
  1114. UINT _uSelectionStateChanged; // selection/focus change bits for _fSelectionChangePending
  1115. UINT _uAutoSelChangeState; // selection/focus change bits for _bAutoSelChangeTimerSet
  1116. DWORD _dwConnectionCookie;
  1117. CBackgroundInfoTip * _pBackgroundInfoTip; // Used for the background InfoTip
  1118. CDefviewEnumTask * _pEnumTask;
  1119. DWORD _dwProffered; // Cookie for the SID_SFolderView service proffered
  1120. PFDVENUMREADYBALLBACK _pfnEnumReadyCallback; // Callback indicating that our enum is done and that the client
  1121. // can now get the IEnumIDList
  1122. void * _pvEnumCallbackData;
  1123. IUIElement* _pOtherPlacesHeader;
  1124. IUIElement* _pDetailsHeader;
  1125. SFVM_WEBVIEW_LAYOUT_DATA _wvLayout; // layout can change on view mode changes
  1126. SFVM_WEBVIEW_CONTENT_DATA _wvContent; // content that is static per folder
  1127. SFVM_WEBVIEW_TASKSECTION_DATA _wvTasks; // content that can change when selection changes
  1128. SFVM_WEBVIEW_THEME_DATA _wvTheme; // HACK: theme info
  1129. BOOL _fBarrierDisplayed; // TRUE if the soft barrier is currently being displayed
  1130. BOOL _fRcvdContentsChangeBeforeDuiViewCreated;
  1131. #ifdef DEBUG
  1132. TIMEVAR(_Update);
  1133. TIMEVAR(_Fill);
  1134. TIMEVAR(_GetIcon);
  1135. TIMEVAR(_GetName);
  1136. TIMEVAR(_FSNotify);
  1137. TIMEVAR(_AddObject);
  1138. TIMEVAR(_EnumNext);
  1139. TIMEVAR(_RestoreState);
  1140. TIMEVAR(_WMNotify);
  1141. TIMEVAR(_LVChanging);
  1142. TIMEVAR(_LVChanged);
  1143. TIMEVAR(_LVDelete);
  1144. TIMEVAR(_LVGetDispInfo);
  1145. #endif
  1146. public: // TODO: Make this protected after we have finished converting the entire file.
  1147. BOOL IsSafeToDefaultVerb(void);
  1148. HRESULT _InvokeContextMenuVerb(IContextMenu* pcm, LPCSTR pszVerb, UINT uKeyFlags, DWORD dwCMMask);
  1149. HRESULT _InvokeContextMenuVerbOnSelection(LPCSTR pszVerb, UINT uKeyFlags, DWORD dwCMMask);
  1150. HRESULT _InvokeContextMenu(IContextMenu *pcm, CMINVOKECOMMANDINFOEX *pici);
  1151. void _LogDesktopLinksAndRegitems();
  1152. void _FocusOnSomething(void);
  1153. void _UpdateIcon(LPITEMIDLIST pidl, UINT iIcon);
  1154. void _UpdateGroup(CBackgroundGroupInfo* pbggi);
  1155. void _UpdateColData(CBackgroundColInfo *pbgci);
  1156. void _UpdateOverlay(int iList, int iOverlay);
  1157. HRESULT _GetIconAsync(LPCITEMIDLIST pidl, int *piIcon, BOOL fCanWait);
  1158. HRESULT _GetOverlayIndexAsync(LPCITEMIDLIST pidl, int iList);
  1159. DWORD _GetNeededSecurityAction(void);
  1160. HRESULT _ZoneCheck(DWORD dwFlags, DWORD dwAllowAction);
  1161. void _ShowAndActivate();
  1162. void _RegisterWindow();
  1163. static LRESULT CALLBACK s_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  1164. LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  1165. static DWORD WINAPI BackgroundDestroyWindow(void *pvData);
  1166. private:
  1167. ~CDefView();
  1168. // View Mode Methods (private)
  1169. //
  1170. BOOL _ViewSupported(UINT uView);
  1171. void _ThumbstripSendImagePreviewFocusChangeEvent();
  1172. // Infotip Methods (private)
  1173. //
  1174. typedef struct {
  1175. HWND hwndContaining;
  1176. UINT_PTR uToolID;
  1177. RECT rectTool;
  1178. } PENDING_INFOTIP;
  1179. CList<PENDING_INFOTIP> _tlistPendingInfotips;
  1180. HRESULT _FindPendingInfotip(HWND hwndContaining, UINT_PTR uToolID, LPRECT prectTool, BOOL bRemoveAndDestroy); // ui thread
  1181. HRESULT _OnPostCreateInfotip(TOOLINFO *pti, LPARAM lParam); // ui thread
  1182. HRESULT _OnPostCreateInfotipCleanup(TOOLINFO *pti); // ui thread or bg thread
  1183. HWND _CreateInfotipControl(HWND hwndParent);
  1184. void _InitInfotipControl(HWND hwndInfotip);
  1185. // Menu Methods (private)
  1186. //
  1187. void _InitViewMenuWhenBarrierDisplayed(HMENU hmenuView); // Initializes entire view menu (for barricaded view).
  1188. void _InitViewMenuWhenBarrierNotDisplayed(HMENU hmenuView); // Initializes entire view menu (for non-barricaded view).
  1189. void _InitViewMenuViewsWhenBarrierNotDisplayed(HMENU hmenuView);// Initializes "view" subsection of view menu (for non-barricated view).
  1190. void _MergeViewMenu(HMENU hmenuViewParent, HMENU hmenuMerge); // Merges hmenuMerge into the view menu @ FCIDM_MENU_VIEW_SEP_OPTIONS
  1191. // Toolbar Methods (private)
  1192. //
  1193. BOOL _ShouldEnableToolbarButton(UINT uiCmd, DWORD dwAttr, int iIndex);
  1194. void _EnableToolbarButton(IExplorerToolbar *piet, UINT uiCmd, BOOL bEnable);
  1195. void _EnableDisableTBButtons();
  1196. void MergeToolBar(BOOL bCanRestore);
  1197. BOOL _MergeIExplorerToolbar(UINT cExtButtons);
  1198. void _CopyDefViewButton(PTBBUTTON ptbbDest, PTBBUTTON ptbbSrc);
  1199. int _GetButtons(PTBBUTTON* ppbtn, LPINT pcButtons, LPINT pcTotalButtons);
  1200. void _SetCachedToolbarSelectionAttrs(ULONG dwAttrs);
  1201. BOOL _GetCachedToolbarSelectionAttrs(ULONG *pdwAttr);
  1202. LRESULT _OnFSNotify(LONG lNotification, LPCITEMIDLIST* ppidl);
  1203. static int CALLBACK _Compare(void *p1, void *p2, LPARAM lParam);
  1204. HRESULT _Sort(void);
  1205. UINT _GetBackgroundTaskCount(REFTASKOWNERID rtid);
  1206. void _SetSortFeedback();
  1207. BOOL GetViewState();
  1208. DWORD _AttributesFromSel(DWORD dwAttrMask);
  1209. HRESULT _GetSelectionDataObject(IDataObject **pdobjSelect);
  1210. HRESULT _GetUIObjectFromItem(REFIID riid, void **ppv, UINT uItem, BOOL fSetPoints);
  1211. HRESULT _GetItemObjects(LPCITEMIDLIST **ppidl, UINT uItem, UINT *pcItems);
  1212. UINT _GetItemArray(LPCITEMIDLIST apidl[], UINT capidl, UINT uWhat);
  1213. BOOL _AllowCommand(UINT uID);
  1214. void _DoStatusBar(BOOL fInitialize);
  1215. void _UpdateStatusBar(BOOL fInitialize);
  1216. void _ShowSearchUI(BOOL fStartSearchWindow);
  1217. HRESULT _OnStartBackgroundEnum();
  1218. HRESULT _OnStopBackgroundEnum();
  1219. HRESULT _OnBackgroundEnumDone();
  1220. LRESULT _GetDisplayInfo(LV_DISPINFO *plvdi);
  1221. UINT _GetHeaderCount();
  1222. BOOL _EnsureSCIDCache();
  1223. BOOL _MapSCIDToColumn(const SHCOLUMNID *pscid, UINT *pnColumn);
  1224. HRESULT _GetSFVMViewState(UINT uViewMode, SFVM_VIEW_DATA* pvi);
  1225. HRESULT _GetSFVMViewInfoTemplate(UINT uViewMode, SFVM_WEBVIEW_TEMPLATE_DATA* pvit);
  1226. int _CompareIDsDirection(LPARAM lParam, LPCITEMIDLIST p1, LPCITEMIDLIST p2);
  1227. HRESULT _CompareIDsFallback(LPARAM lParam, LPCITEMIDLIST p1, LPCITEMIDLIST p2);
  1228. int _FreezeRecycleBin(LPPOINT ppt);
  1229. void _SetRecycleBinInDefaultPosition(POINT *ppt);
  1230. void _ClearItemPositions();
  1231. static void CALLBACK _AsyncIconTaskCallback(LPCITEMIDLIST pidl, void *pvData, void *pvHint, INT iIconIndex, INT iOpenIconIndex);
  1232. void _SetDefaultViewSettings();
  1233. HRESULT _Create_BackgrndHMENU(BOOL fViewMenuOnly, REFIID riid, void **ppv);
  1234. HRESULT _CBackgrndMenu_CreateInstance(REFIID riid, void **ppv);
  1235. friend class CSFVSite;
  1236. friend class CSFVFrame;
  1237. friend class CBkgrndEnumTask;
  1238. friend class CViewState;
  1239. friend class CDefviewEnumTask;
  1240. IDispatch *_pauto; // folder view automation object
  1241. IAdviseSink *_padvise; // advisory connection
  1242. DWORD _advise_aspect;
  1243. DWORD _advise_advf;
  1244. // Is this folder customizable using a desktop.ini?
  1245. // In other words, is this folder in a write-able media AND either it
  1246. // not have a desktop.ini OR if it is there, it is writeable!
  1247. int _iCustomizable;
  1248. HRESULT _CreateSelectionContextMenu(REFIID riid, void** ppv);
  1249. HRESULT _DoBulkRename(LPCITEMIDLIST pidlNewName);
  1250. BOOL _bReEntrantReload;
  1251. IPropertyUI *_ppui;
  1252. };
  1253. int CALLBACK GroupCompare(int iGroup1, int iGroup2, void *pvData);
  1254. // Called CSHRegKey because ATL already has a class called CRegKey.
  1255. class CSHRegKey
  1256. {
  1257. public:
  1258. CSHRegKey(HKEY hkParent, LPCTSTR pszSubKey, BOOL bCreate=FALSE)
  1259. {
  1260. DebugMsg(TF_LIFE, TEXT("ctor CSHRegKey(%s) %x"), pszSubKey, this);
  1261. if ((bCreate ? RegCreateKey(hkParent, pszSubKey, &_hk)
  1262. : RegOpenKeyEx(hkParent, pszSubKey, 0, KEY_READ, &_hk))!=ERROR_SUCCESS)
  1263. {
  1264. _hk = NULL;
  1265. }
  1266. }
  1267. CSHRegKey(HKEY hk) { DebugMsg(TF_LIFE, TEXT("ctor CSHRegKey %x"), this); _hk=hk; }
  1268. ~CSHRegKey()
  1269. {
  1270. DebugMsg(TF_LIFE, TEXT("dtor CSHRegKey %x"), this);
  1271. if (_hk) RegCloseKey(_hk);
  1272. }
  1273. operator HKEY() const { return(_hk); }
  1274. operator !() const { return(_hk==NULL); }
  1275. HRESULT QueryValue(LPCTSTR szSub, LPTSTR pszVal, LONG cb)
  1276. { return(SHRegQueryValue(_hk, szSub, pszVal, &cb)); }
  1277. HRESULT QueryValueEx(LPCTSTR szSub, LPBYTE pszVal, LONG cb)
  1278. { return(SHQueryValueEx(_hk, szSub, 0, NULL, pszVal, (LPDWORD)&cb)); }
  1279. private:
  1280. HKEY _hk;
  1281. };
  1282. class CColumnDlg
  1283. {
  1284. public:
  1285. CColumnDlg(CDefView *pdsv);
  1286. ~CColumnDlg();
  1287. HRESULT ShowDialog(HWND hwnd);
  1288. private:
  1289. void _OnInitDlg();
  1290. BOOL _SaveState();
  1291. void _MoveItem(int iDelta);
  1292. void _UpdateDlgButtons(NMLISTVIEW *pnmlv);
  1293. UINT _HelpIDForItem(int iItem, LPTSTR pszHelpFile, UINT cch);
  1294. HRESULT _GetPropertyUI(IPropertyUI **pppui);
  1295. CDefView *_pdsv;
  1296. IPropertyUI *_ppui;
  1297. HWND _hdlg;
  1298. HWND _hwndLVAll;
  1299. UINT _cColumns;
  1300. UINT *_pdwOrder;
  1301. int *_pWidths;
  1302. BOOL _bChanged;
  1303. BOOL _bLoaded;
  1304. BOOL _bUpdating; // used to block notification processing while we're updating
  1305. static BOOL_PTR CALLBACK s_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  1306. BOOL_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  1307. };
  1308. // Thumbnail helpers
  1309. void ListView_InvalidateImageIndexes(HWND hwndList);
  1310. #define DEFVIEW_LISTCALLBACK_FLAGS (LVIF_TEXT | LVIF_IMAGE | LVIF_GROUPID | LVIF_COLUMNS)
  1311. #define PRIORITY_NORMAL ITSAT_DEFAULT_PRIORITY
  1312. #define PRIORITY_M5 (PRIORITY_NORMAL - 5 * 0x1000)
  1313. #define PRIORITY_M4 (PRIORITY_NORMAL - 4 * 0x1000)
  1314. #define PRIORITY_M3 (PRIORITY_NORMAL - 3 * 0x1000)
  1315. #define PRIORITY_M2 (PRIORITY_NORMAL - 2 * 0x1000)
  1316. #define PRIORITY_M1 (PRIORITY_NORMAL - 1 * 0x1000)
  1317. #define PRIORITY_NORMAL ITSAT_DEFAULT_PRIORITY
  1318. #define PRIORITY_P1 (PRIORITY_NORMAL + 1 * 0x1000)
  1319. #define PRIORITY_P2 (PRIORITY_NORMAL + 2 * 0x1000)
  1320. #define PRIORITY_P3 (PRIORITY_NORMAL + 3 * 0x1000)
  1321. #define PRIORITY_P4 (PRIORITY_NORMAL + 4 * 0x1000)
  1322. #define PRIORITY_P5 (PRIORITY_NORMAL + 5 * 0x1000)
  1323. // The following should be used as returns from GetLocation
  1324. #define PRIORITY_EXTRACT_FAST PRIORITY_P1
  1325. #define PRIORITY_EXTRACT_NORMAL PRIORITY_NORMAL
  1326. #define PRIORITY_EXTRACT_SLOW PRIORITY_M1
  1327. // The following are some basis for background tasks
  1328. #define PRIORITY_IMAGEEXTRACT PRIORITY_EXTRACT_NORMAL
  1329. #define PRIORITY_READAHEAD_EXTRACT PRIORITY_M2
  1330. #define PRIORITY_READAHEAD PRIORITY_M3
  1331. #define PRIORITY_UPDATEDIR PRIORITY_M3
  1332. #define PRIORITY_CACHETIDY PRIORITY_M4
  1333. // The following are some increments used for subtasks in image extraction
  1334. // They are used to alter the priorities above as in these examples, such that
  1335. // disk cache hits are faster than extracts which are faster than cache writes:
  1336. // A fast image extract (3 tasks):
  1337. // PRIORITY_IMAGEEXTRACT + PRIORITY_DELTA_FAST - PRIORITY_DELTA_DISKCACHE == 0x10000010
  1338. // PRIORITY_IMAGEEXTRACT + PRIORITY_DELTA_FAST - PRIORITY_DELTA_EXTRACT == 0x0FFFFF10
  1339. // PRIORITY_IMAGEEXTRACT + PRIORITY_DELTA_FAST - PRIORITY_DELTA_WRITE == 0x0FFFFED0
  1340. // A slow folder extract (2 tasks):
  1341. // PRIORITY_IMAGEEXTRACT - PRIORITY_DELTA_SLOW - PRIORITY_DELTA_DISKCACHE == 0x0FFFFFB0
  1342. // PRIORITY_IMAGEEXTRACT - PRIORITY_DELTA_SLOW - PRIORITY_DELTA_EXTRACT == 0x0FFFFEB0
  1343. // Notice that tasks are done in correct priority order
  1344. #define PRIORITY_DELTA_DISKCACHE 0x00000000 // This has to be the fastest task...
  1345. #define PRIORITY_DELTA_EXTRACT 0x00000100 // We want Extract to be second for most cases
  1346. #define PRIORITY_DELTA_WRITE 0x00000140 // Write tasks should be after all but the slowest extract tasks
  1347. #define PRIORITY_DELTA_FAST 0x00000010
  1348. #define PRIORITY_DELTA_SLOW 0x00000050
  1349. // Flags for _AddTask
  1350. #define ADDTASK_ATFRONT 0x00000001
  1351. #define ADDTASK_ATEND 0x00000002
  1352. #define ADDTASK_ONLYONCE 0x00000004
  1353. //
  1354. // define MAX_ICON_WAIT to be the most (in ms) we will ever wait for a
  1355. // icon to be extracted.
  1356. // define MIN_ICON_WAIT to be amount of time that has to go by
  1357. // before we start waiting again.
  1358. #define MAX_ICON_WAIT 500
  1359. #define MIN_ICON_WAIT 2500
  1360. // PRIORITIES for tasks added to the DefView background task scheduler
  1361. #define TASK_PRIORITY_BKGRND_FILL ITSAT_DEFAULT_PRIORITY
  1362. #define TASK_PRIORITY_GET_ICON ITSAT_DEFAULT_PRIORITY
  1363. #define TASK_PRIORITY_FILE_PROPS PRIORITY_M3 // This is for TileView columns, we don't want to hold icon extraction for this.
  1364. #define TASK_PRIORITY_INFOTIP ITSAT_DEFAULT_PRIORITY
  1365. #define TASK_PRIORITY_GETSTATE PRIORITY_M5 // This is not hi-pri: figuring out the task list.
  1366. #define TASK_PRIORITY_GROUP PRIORITY_P1 // Needs to be higher than icon extraction. Happens after background fill
  1367. #define DEFVIEW_THREAD_IDLE_TIMEOUT (1000 * 60 * 2)
  1368. #define DV_IDTIMER_START_ANI 1 // start the animation (after we started bk enum)
  1369. #define DV_IDTIMER_BUFFERED_REFRESH 3
  1370. #define DV_IDTIMER_NOTIFY_AUTOMATION_SELCHANGE 4
  1371. #define DV_IDTIMER_NOTIFY_AUTOMATION_NOSELCHANGE 5
  1372. #define DV_IDTIMER_DISKCACHE 6
  1373. #define DV_IDTIMER_NOTIFY_AUTOMATION_CONTENTSCHANGED 7
  1374. #define DV_IDTIMER_SCROLL_TIMEOUT 8
  1375. #define DEFSIZE_BORDER 10
  1376. #define DEFSIZE_VERTBDR 30
  1377. #define MAX_WRITECACHE_TASKS 256
  1378. #define WM_USER_DELAY_NAVIGATION (WM_USER + 0x1BA) // random - can be moved - used by DUI and CPL
  1379. INT ScaleSizeBasedUponLocalization (INT iSize);
  1380. #endif // _DEFVIEWP_H_