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.

613 lines
31 KiB

  1. #ifndef _NSC_C
  2. #define _NSC_C
  3. #include "droptgt.h"
  4. #include "iface.h"
  5. #include "dpastuff.h"
  6. #include "cwndproc.h"
  7. #include "resource.h"
  8. #include "inetnot.h"
  9. #include "cowsite.h"
  10. #include <shlobj.h>
  11. #include <cfdefs.h> // LPCOBJECTINFO
  12. #define ID_CONTROL 100
  13. #define ID_HEADER 101
  14. typedef enum
  15. {
  16. NSIF_HITEM = 0x0001,
  17. NSIF_FOLDER = 0x0002,
  18. NSIF_PARENTFOLDER = 0x0004,
  19. NSIF_IDLIST = 0x0008,
  20. NSIF_FULLIDLIST = 0x0010,
  21. NSIF_ATTRIBUTES = 0x0020
  22. } NSI_FLAGS;
  23. typedef enum
  24. {
  25. NSSR_ENUMBELOWROOT = 0x0001,
  26. NSSR_CREATEPIDL = 0x0002
  27. } NSSR_FLAGS;
  28. typedef struct
  29. {
  30. PORDERITEM poi;
  31. DWORD dwSig; // Signature of the item, so we can find it back after async processing
  32. BITBOOL fPinned:1; // is this url pinned in the cache?
  33. BITBOOL fGreyed:1; // draw the item greyed (if offline & not in cache)
  34. BITBOOL fFetched:1; // have we fetched the pinned/greyed state?
  35. BITBOOL fDontRefetch:1; // can't be cached by wininet
  36. BOOL fNavigable:1; // item can be navigated to
  37. } ITEMINFO;
  38. typedef struct
  39. {
  40. const SHCOLUMNID *pscid;
  41. int iFldrCol; // index for this column in GetDetailsOf
  42. TCHAR szName[MAX_COLUMN_NAME_LEN];
  43. DWORD fmt;
  44. int cxChar;
  45. } HEADERINFO;
  46. // Forward decls
  47. struct NSC_BKGDENUMDONEDATA;
  48. // _FrameTrack flags
  49. #define TRACKHOT 0x0001
  50. #define TRACKEXPAND 0x0002
  51. #define TRACKNOCHILD 0x0004
  52. // _DrawItem flags
  53. #define DIICON 0x0001
  54. #define DIRTLREADING 0x0002
  55. #define DIHOT 0x0004
  56. #define DIFIRST 0x0020
  57. #define DISUBITEM 0x0040
  58. #define DILAST 0x0080
  59. #define DISUBLAST (DISUBITEM | DILAST)
  60. #define DIACTIVEBORDER 0x0100
  61. #define DISUBFIRST (DISUBITEM | DIFIRST)
  62. #define DIPINNED 0x0400 // overlay pinned glyph
  63. #define DIGREYED 0x0800 // draw greyed
  64. #define DIFOLDEROPEN 0x1000
  65. #define DIFOLDER 0x2000 //item is a folder
  66. #define DIFOCUSRECT 0x4000
  67. #define DIRIGHT 0x8000 //right aligned
  68. #define NSC_TVIS_MARKED 0x1000
  69. // async icon/url extract flags
  70. #define NSCICON_GREYED 0x0001
  71. #define NSCICON_PINNED 0x0002
  72. #define NSCICON_DONTREFETCH 0x0004
  73. #define WM_NSCUPDATEICONINFO WM_USER + 0x700
  74. #define WM_NSCBACKGROUNDENUMDONE WM_USER + 0x701
  75. #define WM_NSCUPDATEICONOVERLAY WM_USER + 0x702
  76. HRESULT GetNavTargetName(IShellFolder* pFolder, LPCITEMIDLIST pidl, LPTSTR pszUrl, UINT cMaxChars);
  77. BOOL MayBeUnavailableOffline(LPTSTR pszUrl);
  78. INSCTree2 * CNscTree_CreateInstance(void);
  79. STDAPI CNscTree_CreateInstance(IUnknown * punkOuter, IUnknown ** ppunk, LPCOBJECTINFO poi);
  80. BOOL IsExpandableChannelFolder(IShellFolder *psf, LPCITEMIDLIST pidl);
  81. // class wrapper for tree control component of nscband.
  82. class ATL_NO_VTABLE CNscTree :
  83. public CComObjectRootEx<CComMultiThreadModelNoCS>,
  84. public CComCoClass<CNscTree, &CLSID_ShellNameSpace>,
  85. public CComControl<CNscTree>,
  86. public IDispatchImpl<IShellNameSpace, &IID_IShellNameSpace, &LIBID_SHDocVw, 1, 0, CComTypeInfoHolder>,
  87. public IProvideClassInfo2Impl<&CLSID_ShellNameSpace, &DIID_DShellNameSpaceEvents, &LIBID_SHDocVw, 1, 0, CComTypeInfoHolder>,
  88. public IPersistStreamInitImpl<CNscTree>,
  89. public IPersistPropertyBagImpl<CNscTree>,
  90. public IQuickActivateImpl<CNscTree>,
  91. public IOleControlImpl<CNscTree>,
  92. public IOleObjectImpl<CNscTree>,
  93. public IOleInPlaceActiveObjectImpl<CNscTree>,
  94. public IViewObjectExImpl<CNscTree>,
  95. public IOleInPlaceObjectWindowlessImpl<CNscTree>,
  96. public ISpecifyPropertyPagesImpl<CNscTree>,
  97. public IConnectionPointImpl<CNscTree, &DIID_DShellNameSpaceEvents, CComDynamicUnkArray>,
  98. public IConnectionPointContainerImpl<CNscTree>,
  99. public IShellChangeNotify,
  100. public CDelegateDropTarget,
  101. public CNotifySubclassWndProc,
  102. public CObjectWithSite,
  103. public INSCTree2,
  104. public IWinEventHandler,
  105. public IShellBrowser,
  106. public IFolderFilterSite
  107. {
  108. public:
  109. DECLARE_WND_CLASS(TEXT("NamespaceOC Window"))
  110. DECLARE_NO_REGISTRY();
  111. BEGIN_COM_MAP(CNscTree)
  112. COM_INTERFACE_ENTRY(IShellNameSpace)
  113. COM_INTERFACE_ENTRY(IDispatch)
  114. COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  115. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  116. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  117. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  118. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  119. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  120. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  121. COM_INTERFACE_ENTRY_IMPL(IOleControl)
  122. COM_INTERFACE_ENTRY_IMPL(IOleObject)
  123. COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
  124. COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit)
  125. COM_INTERFACE_ENTRY_IMPL(ISpecifyPropertyPages)
  126. COM_INTERFACE_ENTRY(IProvideClassInfo)
  127. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  128. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  129. COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
  130. COM_INTERFACE_ENTRY(IShellChangeNotify) // IID_IShellChangeNotify
  131. COM_INTERFACE_ENTRY(INSCTree) // IID_INSCTree
  132. COM_INTERFACE_ENTRY(INSCTree2) // IID_INSCTree2
  133. COM_INTERFACE_ENTRY(IShellFavoritesNameSpace) // IID_IShellFavoritesNameSpace
  134. COM_INTERFACE_ENTRY(IShellNameSpace) // IID_IShellNameSpace
  135. COM_INTERFACE_ENTRY(IWinEventHandler) // IID_IWinEventHandler
  136. COM_INTERFACE_ENTRY(IDropTarget) // IID_IDropTarget
  137. COM_INTERFACE_ENTRY(IObjectWithSite) // IID_IObjectWithSite
  138. COM_INTERFACE_ENTRY(IShellBrowser) // IID_IShellBrowser
  139. COM_INTERFACE_ENTRY(IFolderFilterSite) // IID_IFolderFilterSite
  140. END_COM_MAP()
  141. BEGIN_PROPERTY_MAP(CNscTree)
  142. PROP_ENTRY("Root", DISPID_ROOT, CLSID_NULL)
  143. PROP_ENTRY("EnumOptions", DISPID_ENUMOPTIONS, CLSID_NULL)
  144. PROP_ENTRY("Flags", DISPID_FLAGS, CLSID_NULL)
  145. PROP_ENTRY("Depth", DISPID_DEPTH, CLSID_NULL)
  146. PROP_ENTRY("Mode", DISPID_MODE, CLSID_NULL)
  147. PROP_ENTRY("TVFlags", DISPID_TVFLAGS, CLSID_NULL)
  148. PROP_ENTRY("Columns", DISPID_NSCOLUMNS, CLSID_NULL)
  149. END_PROPERTY_MAP()
  150. BEGIN_MSG_MAP(CNscTree)
  151. MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
  152. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  153. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  154. MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate)
  155. MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
  156. MESSAGE_HANDLER(CWM_GETISHELLBROWSER, OnGetIShellBrowser)
  157. END_MSG_MAP()
  158. BEGIN_CONNECTION_POINT_MAP(CNscTree)
  159. CONNECTION_POINT_ENTRY(DIID_DShellNameSpaceEvents)
  160. END_CONNECTION_POINT_MAP()
  161. // IObjectWithSite
  162. STDMETHODIMP SetSite(IUnknown *punkSite);
  163. // INSCTree
  164. STDMETHODIMP CreateTree(HWND hwndParent, DWORD dwStyles, HWND *phwnd); // create window of tree view.
  165. STDMETHODIMP Initialize(LPCITEMIDLIST pidlRoot, DWORD grfFlags, DWORD dwFlags); // init the treeview control with data.
  166. STDMETHODIMP ShowWindow(BOOL fShow);
  167. STDMETHODIMP Refresh(void);
  168. STDMETHODIMP GetSelectedItem(LPITEMIDLIST * ppidl, int nItem);
  169. STDMETHODIMP SetSelectedItem(LPCITEMIDLIST pidl, BOOL fCreate, BOOL fReinsert, int nItem);
  170. STDMETHODIMP GetNscMode(UINT * pnMode) { *pnMode = _mode; return S_OK;};
  171. STDMETHODIMP SetNscMode(UINT nMode) { _mode = nMode; return S_OK;};
  172. STDMETHODIMP GetSelectedItemName(LPWSTR pszName, DWORD cchName);
  173. STDMETHODIMP BindToSelectedItemParent(REFIID riid, void **ppv, LPITEMIDLIST *ppidl);
  174. STDMETHODIMP_(BOOL) InLabelEdit(void) {return _fInLabelEdit;};
  175. // INSCTree2
  176. STDMETHODIMP RightPaneNavigationStarted(LPITEMIDLIST pidl);
  177. STDMETHODIMP RightPaneNavigationFinished(LPITEMIDLIST pidl);
  178. STDMETHODIMP CreateTree2(HWND hwndParent, DWORD dwStyle, DWORD dwExStyle, HWND *phwnd); // create window of tree view.
  179. // IShellBrowser (Hack)
  180. STDMETHODIMP InsertMenusSB(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths) {return E_NOTIMPL;};
  181. STDMETHODIMP SetMenuSB(HMENU hmenuShared, HOLEMENU holemenu, HWND hwnd) {return E_NOTIMPL;};
  182. STDMETHODIMP RemoveMenusSB(HMENU hmenuShared) {return E_NOTIMPL;};
  183. STDMETHODIMP SetStatusTextSB(LPCOLESTR lpszStatusText) {return E_NOTIMPL;};
  184. STDMETHODIMP EnableModelessSB(BOOL fEnable) {return E_NOTIMPL;};
  185. STDMETHODIMP TranslateAcceleratorSB(LPMSG lpmsg, WORD wID) {return E_NOTIMPL;};
  186. STDMETHODIMP BrowseObject(LPCITEMIDLIST pidl, UINT wFlags) {return E_NOTIMPL;};
  187. STDMETHODIMP GetViewStateStream(DWORD grfMode, LPSTREAM *ppStrm) {return E_NOTIMPL; };
  188. STDMETHODIMP GetControlWindow(UINT id, HWND * lphwnd) {return E_NOTIMPL;};
  189. STDMETHODIMP SendControlMsg(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret) {return E_NOTIMPL;};
  190. STDMETHODIMP QueryActiveShellView(struct IShellView ** ppshv) {return E_NOTIMPL;};
  191. STDMETHODIMP OnViewWindowActive(struct IShellView * ppshv) {return E_NOTIMPL;};
  192. STDMETHODIMP SetToolbarItems(LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags) {return E_NOTIMPL;};
  193. //STDMETHODIMP GetWindow(HWND * lphwnd) {return E_NOTIMPL;}; //already defined in IOleWindow
  194. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode) {return E_NOTIMPL;};
  195. // IWinEventHandler
  196. STDMETHODIMP OnWinEvent(HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  197. STDMETHODIMP IsWindowOwner(HWND hwnd) {return E_NOTIMPL;};
  198. // IShellChangeNotify
  199. STDMETHODIMP OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  200. // IShellNameSpace
  201. STDMETHODIMP get_SubscriptionsEnabled(VARIANT_BOOL *pVal);
  202. STDMETHODIMP Import() {return DoImportOrExport(TRUE);};
  203. STDMETHODIMP Export() {return DoImportOrExport(FALSE);};
  204. STDMETHODIMP Synchronize();
  205. STDMETHODIMP NewFolder();
  206. STDMETHODIMP ResetSort();
  207. STDMETHODIMP MoveSelectionDown() {MoveItemUpOrDown(FALSE); return S_OK;};
  208. STDMETHODIMP MoveSelectionUp() {MoveItemUpOrDown(TRUE); return S_OK;};
  209. STDMETHODIMP InvokeContextMenuCommand(BSTR strCommand);
  210. STDMETHODIMP MoveSelectionTo();
  211. STDMETHODIMP CreateSubscriptionForSelection(/*[out, retval]*/ VARIANT_BOOL *pBool);
  212. STDMETHODIMP DeleteSubscriptionForSelection(/*[out, retval]*/ VARIANT_BOOL *pBool);
  213. STDMETHODIMP get_EnumOptions(LONG *pVal);
  214. STDMETHODIMP put_EnumOptions(LONG lVal);
  215. STDMETHODIMP get_SelectedItem(IDispatch **ppItem);
  216. STDMETHODIMP put_SelectedItem(IDispatch *pItem);
  217. STDMETHODIMP get_Root(VARIANT *pvar);
  218. STDMETHODIMP put_Root(VARIANT pItem);
  219. STDMETHODIMP SetRoot(BSTR bstrRoot);
  220. STDMETHODIMP put_Depth(int iDepth){ return S_OK;};
  221. STDMETHODIMP get_Depth(int *piDepth){ *piDepth = 1; return S_OK;};
  222. STDMETHODIMP put_Mode(UINT uMode);
  223. STDMETHODIMP get_Mode(UINT *puMode) { *puMode = _mode; return S_OK;};
  224. STDMETHODIMP put_Flags(DWORD dwFlags);
  225. STDMETHODIMP get_Flags(DWORD *pdwFlags) { *pdwFlags = _dwFlags; return S_OK;};
  226. STDMETHODIMP put_TVFlags(DWORD dwFlags) { _dwTVFlags = dwFlags; return S_OK;};
  227. STDMETHODIMP get_TVFlags(DWORD *dwFlags) { *dwFlags = _dwTVFlags; return S_OK;};
  228. STDMETHODIMP put_Columns(BSTR bstrColumns);
  229. STDMETHODIMP get_Columns(BSTR *bstrColumns);
  230. STDMETHODIMP get_CountViewTypes(int *piTypes);
  231. STDMETHODIMP SetViewType(int iType);
  232. STDMETHODIMP SelectedItems(IDispatch **ppItems);
  233. STDMETHODIMP Expand(VARIANT var, int iDepth);
  234. //STDMETHODIMP get_ReadyState(READYSTATE *plReady);
  235. STDMETHODIMP UnselectAll();
  236. // IViewObjectEx
  237. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  238. {
  239. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  240. *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
  241. return S_OK;
  242. }
  243. // IOleInPlaceObject
  244. STDMETHODIMP SetObjectRects(LPCRECT prcPos, LPCRECT prcClip);
  245. // IOleInPlaceActiveObjectImpl
  246. STDMETHODIMP TranslateAccelerator(MSG *pMsg);
  247. // IOleWindow
  248. STDMETHODIMP GetWindow(HWND *phwnd);
  249. // IOleObject
  250. STDMETHODIMP SetClientSite(IOleClientSite *pClientSite);
  251. // CDelegateDropTarget
  252. virtual HRESULT GetWindowsDDT(HWND * phwndLock, HWND * phwndScroll);
  253. virtual HRESULT HitTestDDT(UINT nEvent, LPPOINT ppt, DWORD_PTR * pdwId, DWORD * pdwDropEffect);
  254. virtual HRESULT GetObjectDDT(DWORD_PTR dwId, REFIID riid, void ** ppvObj);
  255. virtual HRESULT OnDropDDT(IDropTarget *pdt, IDataObject *pdtobj, DWORD * pgrfKeyState, POINTL pt, DWORD *pdwEffect);
  256. // IFolderFilterSite
  257. STDMETHODIMP SetFilter(IUnknown* punk);
  258. CNscTree();
  259. // override ATL default handlers
  260. HRESULT OnDraw(ATL_DRAWINFO& di);
  261. LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  262. LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  263. LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  264. LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  265. LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  266. LRESULT OnGetIShellBrowser(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
  267. HRESULT InPlaceActivate(LONG iVerb, const RECT* prcPosRect = NULL);
  268. HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR pszWindowName = NULL,
  269. DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
  270. DWORD dwExStyle = 0, UINT nID = 0);
  271. HRESULT GetEventInfo(IShellFolder *psf, LPCITEMIDLIST pidl,
  272. UINT *pcItems, LPWSTR pszUrl, DWORD cchUrl,
  273. UINT *pcVisits, LPWSTR pszLastVisited, BOOL *pfAvailableOffline);
  274. protected:
  275. ~CNscTree();
  276. class CSelectionContextMenu : public IContextMenu2
  277. {
  278. friend CNscTree;
  279. protected:
  280. // IUnknown
  281. STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
  282. STDMETHODIMP_(ULONG) AddRef(void) ;
  283. STDMETHODIMP_(ULONG) Release(void);
  284. // IContextMenu
  285. STDMETHODIMP QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
  286. STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
  287. STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uType,
  288. UINT * pwRes, LPSTR pszName, UINT cchMax) { return E_NOTIMPL; };
  289. // IContextMenu2
  290. STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
  291. protected:
  292. ~CSelectionContextMenu();
  293. IContextMenu *_QuerySelection();
  294. IContextMenu *_pcmSelection;
  295. IContextMenu2 *_pcm2Selection;
  296. ULONG _ulRefs;
  297. public:
  298. CSelectionContextMenu() : _pcmSelection(NULL),_ulRefs(0) {}
  299. };
  300. friend class CSelectionContextMenu;
  301. CSelectionContextMenu _scm;
  302. private:
  303. void _FireFavoritesSelectionChange(long cItems, long hItem, BSTR strName,
  304. BSTR strUrl, long cVisits, BSTR strDate, long fAvailableOffline);
  305. HRESULT _InvokeContextMenuCommand(BSTR strCommand);
  306. void _InsertMarkedChildren(HTREEITEM htiParent, LPCITEMIDLIST pidlParent, IInsertItem *pii);
  307. HRESULT _GetEnumFlags(IShellFolder *psf, LPCITEMIDLIST pidlFolder, DWORD *pgrfFlags, HWND *phwnd);
  308. HRESULT _GetEnum(IShellFolder *psf, LPCITEMIDLIST pidlFolder, IEnumIDList **ppenum);
  309. BOOL _ShouldShow(IShellFolder* psf, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlItem);
  310. HWND _CreateTreeview();
  311. HWND _CreateHeader();
  312. void _SubClass(LPCITEMIDLIST pidlRoot);
  313. void _UnSubClass(void);
  314. int _GetChildren(IShellFolder *psf, LPCITEMIDLIST pidl, ULONG ulAttrs);
  315. HRESULT _LoadSF(HTREEITEM htiRoot, LPCITEMIDLIST pidl, BOOL * pfOrdered);
  316. HRESULT _StartBackgroundEnum(HTREEITEM htiRoot, LPCITEMIDLIST pidl,
  317. BOOL * pfOrdered, BOOL fUpdatePidls);
  318. void _GetDefaultIconIndex(LPCITEMIDLIST pidl, ULONG ulAttrs, TVITEM *pitem, BOOL fFolder);
  319. BOOL _LabelEditIsNewValueValid(TV_DISPINFO *ptvdi);
  320. LRESULT _OnEndLabelEdit(TV_DISPINFO *ptvdi);
  321. LRESULT _OnBeginLabelEdit(TV_DISPINFO *ptvdi);
  322. LPITEMIDLIST _CacheParentShellFolder(HTREEITEM hti, LPITEMIDLIST pidl);
  323. BOOL _CacheShellFolder(HTREEITEM hti);
  324. void _CacheDetails();
  325. void _ReleaseRootFolder(void );
  326. void _ReleasePidls(void);
  327. void _ReleaseCachedShellFolder(void);
  328. void _TvOnHide();
  329. void _TvOnShow();
  330. BOOL _ShouldAdd(LPCITEMIDLIST pidl);
  331. void _ReorderChildren(HTREEITEM htiParent);
  332. void _Sort(HTREEITEM hti, IShellFolder *psf);
  333. void MoveItemUpOrDown(BOOL fUp);
  334. LPITEMIDLIST _FindHighestDeadItem(LPCITEMIDLIST pidl);
  335. void _RemoveDeadBranch(LPCITEMIDLIST pidl);
  336. HRESULT CreateNewFolder(HTREEITEM hti);
  337. BOOL MoveItemsIntoFolder(HWND hwndParent);
  338. HRESULT DoImportOrExport(BOOL fImport);
  339. HRESULT DoSubscriptionForSelection(BOOL fCreate);
  340. LRESULT _OnNotify(LPNMHDR pnm);
  341. HRESULT _OnPaletteChanged(WPARAM wPAram, LPARAM lParam);
  342. HRESULT _OnWindowCleanup(void);
  343. HRESULT _HandleWinIniChange(void);
  344. HRESULT _EnterNewFolderEditMode(LPCITEMIDLIST pidlNewFolder);
  345. HTREEITEM _AddItemToTree(HTREEITEM htiParent, LPITEMIDLIST pidl, int cChildren, int iPos,
  346. HTREEITEM htiAfter = TVI_LAST, BOOL fCheckForDups = TRUE, BOOL fMarked = FALSE);
  347. HTREEITEM _FindChild(IShellFolder *psf, HTREEITEM htiParent, LPCITEMIDLIST pidlChild);
  348. LPITEMIDLIST _GetFullIDList(HTREEITEM hti);
  349. ITEMINFO *_GetTreeItemInfo(HTREEITEM hti);
  350. PORDERITEM _GetTreeOrderItem(HTREEITEM hti);
  351. BOOL _SetRoot(LPCITEMIDLIST pidlRoot, int iExpandDepth, LPCITEMIDLIST pidlExpandTo, NSSR_FLAGS flags);
  352. DWORD _SetStyle(DWORD dwStyle);
  353. DWORD _SetExStyle(DWORD dwExStyle);
  354. void _OnGetInfoTip(NMTVGETINFOTIP *pnm);
  355. LRESULT _OnSetCursor(NMMOUSE* pnm);
  356. void _ApplyCmd(HTREEITEM hti, IContextMenu *pcm, UINT cmdId);
  357. HRESULT _QuerySelection(IContextMenu **ppcm, HTREEITEM *phti);
  358. HMENU _CreateContextMenu(IContextMenu *pcm, HTREEITEM hti);
  359. LRESULT _OnContextMenu(short x, short y);
  360. void _OnBeginDrag(NM_TREEVIEW *pnmhdr);
  361. void _OnChangeNotify(LONG lEvent, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra);
  362. HRESULT _OnDeleteItem(NM_TREEVIEW *pnm);
  363. void _OnGetDisplayInfo(TV_DISPINFO *pnm);
  364. HRESULT _ChangePidlRoot(LPCITEMIDLIST pidl);
  365. BOOL _IsExpandable(HTREEITEM hti);
  366. BOOL _OnItemExpandingMsg(NM_TREEVIEW *pnm);
  367. BOOL _OnItemExpanding(HTREEITEM htiToActivate, UINT action, BOOL fExpandedOnce, BOOL fIsExpandPartial);
  368. BOOL _OnSelChange(BOOL fMark);
  369. void _OnSetSelection();
  370. BOOL _FIsItem(IShellFolder * psf, LPCITEMIDLIST pidlTarget, HTREEITEM hti);
  371. HTREEITEM _FindFromRoot(HTREEITEM htiRoot, LPCITEMIDLIST pidl);
  372. HRESULT _OnSHNotifyRename(LPCITEMIDLIST pidl, LPCITEMIDLIST pidlNew);
  373. HRESULT _OnSHNotifyDelete(LPCITEMIDLIST pidl, int *piPosDeleted, HTREEITEM *phtiParent);
  374. void _OnSHNotifyUpdateItem(LPCITEMIDLIST pidl, LPITEMIDLIST pidlReal);
  375. HRESULT _OnSHNotifyUpdateDir(LPCITEMIDLIST pidl);
  376. HRESULT _OnSHNotifyCreate(LPCITEMIDLIST pidl, int iPosition, HTREEITEM htiParent);
  377. void _OnSHNotifyOnlineChange(HTREEITEM htiRoot, BOOL fGoingOnline);
  378. void _OnSHNotifyCacheChange(HTREEITEM htiRoot, DWORD_PTR dwChanged);
  379. HRESULT _IdlRealFromIdlSimple(IShellFolder * psf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST * ppidlReal);
  380. void _DtRevoke();
  381. void _DtRegister();
  382. int _TreeItemIndexInHDPA(HDPA hdpa, IShellFolder *psfParent, HTREEITEM hti, int iReverseStart);
  383. BOOL _IsItemExpanded(HTREEITEM hti);
  384. HRESULT _UpdateDir(HTREEITEM hti, BOOL bUpdatePidls);
  385. HRESULT _GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, LPSHELLDETAILS pdetails);
  386. HRESULT _ParentFromItem(LPCITEMIDLIST pidl, IShellFolder** ppsfParent, LPCITEMIDLIST *ppidlChild);
  387. HRESULT _CompareIDs(IShellFolder *psf, LPITEMIDLIST pidl1, LPITEMIDLIST pidl2);
  388. static int CALLBACK _TreeCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  389. static LRESULT CALLBACK s_SubClassTreeWndProc(
  390. HWND hwnd, UINT uMsg,
  391. WPARAM wParam, LPARAM lParam,
  392. UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
  393. LRESULT _SubClassTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  394. void _InitHeaderInfo();
  395. HRESULT _Expand(LPCITEMIDLIST pidl, int iDepth);
  396. HTREEITEM _ExpandToItem(LPCITEMIDLIST pidl, BOOL fCreate = TRUE, BOOL fReinsert = FALSE);
  397. HRESULT _ExpandNode(HTREEITEM htiParent, int iCode, int iDepth);
  398. HRESULT _PutRootVariant(VARIANT *pvar);
  399. BOOL _IsItemNameInTree(LPCITEMIDLIST pidl);
  400. COLORREF _GetRegColor(COLORREF clrDefault, LPCTSTR pszName);
  401. void _AssignPidl(PORDERITEM poi, LPITEMIDLIST pidlNew);
  402. protected:
  403. // used for background thread icon + draw info extraction
  404. static void s_NscIconCallback(CNscTree *pns, UINT_PTR uId, int iIcon, int iOpenIcon, DWORD dwFlags, UINT uMagic);
  405. static void s_NscOverlayCallback(CNscTree *pns, UINT_PTR uId, int iOverlayIndex, UINT uMagic);
  406. // used for background enumeration
  407. static void s_NscEnumCallback(CNscTree *pns, LPITEMIDLIST pidl, UINT_PTR uId, DWORD dwSig, HDPA hdpa,
  408. LPITEMIDLIST pidlExpandingTo, DWORD dwOrderSig,
  409. UINT uDepth, BOOL fUpdate, BOOL fUpdatePidls);
  410. private:
  411. void _EnumBackgroundDone(NSC_BKGDENUMDONEDATA *pbedd);
  412. #ifdef DEBUG
  413. void TraceHTREE(HTREEITEM hti, LPCTSTR pszDebugMsg);
  414. void TracePIDL(LPCITEMIDLIST pidl, LPCTSTR pszDebugMsg);
  415. void TracePIDLAbs(LPCITEMIDLIST pidl, LPCTSTR pszDebugMsg);
  416. #endif
  417. static int CALLBACK _TreeOrder(LPARAM lParam1, LPARAM lParam2
  418. , LPARAM lParamSort);
  419. BOOL _IsOrdered(HTREEITEM htiRoot);
  420. void _SelectPidl(LPCITEMIDLIST pidl, BOOL fCreate, BOOL fReinsert = FALSE);
  421. void _SelectNoExpand(HWND hwnd, HTREEITEM hti);
  422. HRESULT _InsertChild(HTREEITEM htiParent, IShellFolder *psfParent, LPCITEMIDLIST pidlChild, BOOL fExpand, BOOL fSimpleToRealIDL, int iPosition, HTREEITEM *phti);
  423. LRESULT _OnCommand(WPARAM wParam, LPARAM lParam);
  424. IStream *GetOrderStream(LPCITEMIDLIST pidl, DWORD grfMode);
  425. HRESULT _PopulateOrderList(HTREEITEM htiRoot);
  426. void _FreeOrderList(HTREEITEM htiRoot);
  427. void _Dropped(void);
  428. LRESULT _OnCDNotify(LPNMCUSTOMDRAW pnm);
  429. BOOL _IsTopParentItem(HTREEITEM hti);
  430. BOOL _MoveNode(int _iDragSrc, int iNewPos, LPITEMIDLIST pidl);
  431. void _TreeInvalidateItemInfo(HTREEITEM hItem, UINT mask);
  432. void _InvalidateImageIndex(HTREEITEM hItem, int iImage);
  433. void _DrawItem(HTREEITEM hti, TCHAR * psz, HDC hdc, LPRECT prc,
  434. DWORD dwFlags, int iLevel, COLORREF clrbk, COLORREF clrtxt);
  435. void _DrawIcon(HTREEITEM hti,HDC hdc, int iLevel, RECT *prc, DWORD dwFlags);
  436. void _DrawActiveBorder(HDC hdc, LPRECT prc);
  437. void _UpdateActiveBorder(HTREEITEM htiSelected);
  438. void _MarkChildren(HTREEITEM htiParent, BOOL fOn);
  439. BOOL _IsMarked(HTREEITEM hti);
  440. void _UpdateItemDisplayInfo(HTREEITEM hti);
  441. void _TreeSetItemState(HTREEITEM hti, UINT stateMask, UINT state);
  442. void _TreeNukeCutState();
  443. BOOL _IsChannelFolder(HTREEITEM hti);
  444. BOOL _LoadOrder(HTREEITEM hti, LPCITEMIDLIST pidl, IShellFolder* psf, HDPA* phdpa);
  445. HWND _hwndParent; // parent window to notify
  446. HWND _hwndTree; // tree or combo box
  447. HWND _hwndNextViewer;
  448. HWND _hwndHdr;
  449. DWORD _style;
  450. DWORD _dwExStyle;
  451. DWORD _grfFlags; // Flags to filter what goes in the tree.
  452. DWORD _dwFlags; // Behavior Flags (NSS_*)
  453. DWORD _dwTVFlags;
  454. BITBOOL _fInitialized : 1; // Has INSCTree::Initialize() been called at least once yet?
  455. BITBOOL _fIsSelectionCached: 1; // If the WM_NCDESTROY has been processed, then we squired the selected pidl(s) in _pidlSelected
  456. BITBOOL _fCacheIsDesktop : 1; // state flags
  457. BITBOOL _fAutoExpanding : 1; // tree is auto-expanding
  458. BITBOOL _fDTRegistered:1; // have we registered as droptarget?
  459. BITBOOL _fpsfCacheIsTopLevel : 1; // is the cached psf a root channel ?
  460. BITBOOL _fDragging : 1; // one o items being dragged
  461. BITBOOL _fStartingDrag : 1; // starting to drag an item
  462. BITBOOL _fDropping : 1; // a drop occurred in the nsc
  463. BITBOOL _fInSelectPidl : 1; // we are performing a SelectPidl
  464. BITBOOL _fInserting : 1; // we're on the insertion edge.
  465. BITBOOL _fInsertBefore : 1; // a drop occurred in the nsc
  466. BITBOOL _fClosing : 1; // are we closing ?
  467. BITBOOL _fOkToRename : 1; // are we right clicking.
  468. BITBOOL _fInLabelEdit:1;
  469. BITBOOL _fCollapsing:1; // is a node collapsing.
  470. BITBOOL _fOnline:1; // is inet online?
  471. BITBOOL _fWeChangedOrder:1; // did we change the order?
  472. BITBOOL _fHandlingShellNotification:1; //are we handing a shell notification?
  473. BITBOOL _fSingleExpand:1; // are we in single expand mode
  474. BITBOOL _fHasFocus:1; // does nsc have the focus?
  475. BITBOOL _fIgnoreNextSelChange:1;// hack to get around treeview keydown bug
  476. BITBOOL _fIgnoreNextItemExpanding:1; //hack to get around annoying single expand behavior
  477. BITBOOL _fInExpand:1; // TRUE while we are doing delayed expansion (called back from the secondary thread)
  478. BITBOOL _fSubClassed:1; // Have we subclassed the window yet?
  479. BITBOOL _fAsyncDrop:1; // async drop from outside or another inside folder.
  480. BITBOOL _fOrdered:1; // is root folder ordered.
  481. BITBOOL _fExpandNavigateTo:1; // Do we need to expand when the right pane navigation comes back?
  482. BITBOOL _fNavigationFinished:1; // TRUE when the right hand pane has finished its navigation
  483. BITBOOL _fSelectFromMouseClick:1; // Did we use the mouse to select the item? (as opposed to the keyboard)
  484. BITBOOL _fShouldShowAppStartCursor:1; // TRUE to show the appstart cursor while there is a background task going
  485. BOOL _fUpdate; // true if we are enumerating so that we can update the tree (refresh)
  486. int _cxOldWidth;
  487. UINT _mode;
  488. UINT _csidl;
  489. IContextMenu* _pcm; // context menu currently being displayed
  490. IContextMenu2* _pcmSendTo; // deal with send to hack so messages tgo right place.
  491. LPITEMIDLIST _pidlRoot;
  492. LPITEMIDLIST _pidlSelected; // Valid if _fIsSelectionCached is true. Used for INSCTree::GetSelectedItem() after tree is gone.
  493. HTREEITEM _htiCache; // tree item associated with Current shell folder
  494. IShellFolder* _psfCache; // cache of the last IShellFolder I needed...
  495. IShellFolder2* _psf2Cache; // IShellDetails2 for _psfISD2Cache
  496. IFolderFilter* _pFilter;
  497. INamespaceProxy* _pnscProxy;
  498. ULONG _ulDisplayCol; // Default display col for _psfCache
  499. ULONG _ulSortCol; // Default sort col for _psfCache
  500. ULONG _nChangeNotifyID; // SHChangeNotify registration ID
  501. HDPA _hdpaOrd; // dpa order for current shell folder.
  502. // drop target privates
  503. HTREEITEM _htiCur; // current tree item (dragging over)
  504. DWORD _dwLastTime;
  505. DWORD _dwEffectCur; // current drag effect
  506. int _iDragSrc; // dragging from this pos.
  507. int _iDragDest; // destination drag point
  508. HTREEITEM _htiDropInsert; // parent of inserted item.
  509. HTREEITEM _htiDragging; // the tree item being dragged during D&D.
  510. HTREEITEM _htiCut; // Used for Clipboard and Visuals
  511. LPITEMIDLIST _pidlDrag; // pidl of item being dragged from within.
  512. HTREEITEM _htiFolderStart; // what folder do we start in.
  513. HICON _hicoPinned; // drawn over items that are sticky in the inet cache
  514. HWND _hwndDD; // window to draw custom drag cursors on.
  515. HTREEITEM _htiActiveBorder; // the folder to draw the active border around
  516. CWinInetNotify _inetNotify; // hooks up wininet notifications (online/offline, etc)
  517. IShellTaskScheduler* _pTaskScheduler; // background task icon/info extracter
  518. int _iDefaultFavoriteIcon; // index of default favorite icon in system image list
  519. int _iDefaultFolderIcon; // index of default folder icon in system image list
  520. HTREEITEM _htiRenaming; // hti of item being renamed in rename mode
  521. LPITEMIDLIST _pidlNewFolderParent; // where the new folder will be arriving (when user picks "Create New Folder")
  522. DWORD _dwSignature; // Signature used to track items in the tree, even after they've moved
  523. DWORD _dwOrderSig; // Signature that lets us detect changes in ordering of items
  524. BYTE _bSynchId; // magic number for validating tree during background icon extraction
  525. HDPA _hdpaColumns; // visible columns when NSS_HEADER is set
  526. HDPA _hdpaViews; // ishellfolderviewtype view pidls
  527. LPITEMIDLIST _pidlExpandingTo; // During expansion of the tree, this is the pidl of the item we want to reach.
  528. LPITEMIDLIST _pidlNavigatingTo; // This is the pidl to which the right pane is currently navigating to
  529. UINT _uDepth; // depth of recursive expansion
  530. CRITICAL_SECTION _csBackgroundData; // protects the data from the background tasks.
  531. NSC_BKGDENUMDONEDATA * _pbeddList; // List of tasks that are done.
  532. BITBOOL _fShowCompColor:1; // Show compressed files in different color
  533. enum
  534. {
  535. RSVIDM_CONTEXT_START = RSVIDM_LAST + 1, // our private menu items end here
  536. };
  537. };
  538. int DPADeleteItemCB(void *pItem, void *pData);
  539. int DPADeletePidlsCB(void *pItem, void *pData);
  540. // util macros.
  541. #define GetPoi(p) (((ITEMINFO *)p)->poi)
  542. #define GetPii(p) ((ITEMINFO *)p)
  543. #include "nscband.h"
  544. #endif // _NSC_C