Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

610 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 *_pcmSelection;
  294. IContextMenu2 *_pcm2Selection;
  295. ULONG _ulRefs;
  296. public:
  297. CSelectionContextMenu() : _pcmSelection(NULL),_ulRefs(0) {}
  298. };
  299. friend class CSelectionContextMenu;
  300. CSelectionContextMenu _scm;
  301. private:
  302. void _FireFavoritesSelectionChange(long cItems, long hItem, BSTR strName,
  303. BSTR strUrl, long cVisits, BSTR strDate, long fAvailableOffline);
  304. HRESULT _InvokeContextMenuCommand(BSTR strCommand);
  305. void _InsertMarkedChildren(HTREEITEM htiParent, LPCITEMIDLIST pidlParent, IInsertItem *pii);
  306. HRESULT _GetEnumFlags(IShellFolder *psf, LPCITEMIDLIST pidlFolder, DWORD *pgrfFlags, HWND *phwnd);
  307. HRESULT _GetEnum(IShellFolder *psf, LPCITEMIDLIST pidlFolder, IEnumIDList **ppenum);
  308. BOOL _ShouldShow(IShellFolder* psf, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlItem);
  309. HWND _CreateTreeview();
  310. HWND _CreateHeader();
  311. void _SubClass(LPCITEMIDLIST pidlRoot);
  312. void _UnSubClass(void);
  313. int _GetChildren(IShellFolder *psf, LPCITEMIDLIST pidl, ULONG ulAttrs);
  314. HRESULT _LoadSF(HTREEITEM htiRoot, LPCITEMIDLIST pidl, BOOL * pfOrdered);
  315. HRESULT _StartBackgroundEnum(HTREEITEM htiRoot, LPCITEMIDLIST pidl,
  316. BOOL * pfOrdered, BOOL fUpdatePidls);
  317. void _GetDefaultIconIndex(LPCITEMIDLIST pidl, ULONG ulAttrs, TVITEM *pitem, BOOL fFolder);
  318. BOOL _LabelEditIsNewValueValid(TV_DISPINFO *ptvdi);
  319. LRESULT _OnEndLabelEdit(TV_DISPINFO *ptvdi);
  320. LRESULT _OnBeginLabelEdit(TV_DISPINFO *ptvdi);
  321. LPITEMIDLIST _CacheParentShellFolder(HTREEITEM hti, LPITEMIDLIST pidl);
  322. BOOL _CacheShellFolder(HTREEITEM hti);
  323. void _CacheDetails();
  324. void _ReleaseRootFolder(void );
  325. void _ReleasePidls(void);
  326. void _ReleaseCachedShellFolder(void);
  327. void _TvOnHide();
  328. void _TvOnShow();
  329. void _ReorderChildren(HTREEITEM htiParent);
  330. void _Sort(HTREEITEM hti, IShellFolder *psf);
  331. void MoveItemUpOrDown(BOOL fUp);
  332. LPITEMIDLIST _FindHighestDeadItem(LPCITEMIDLIST pidl);
  333. void _RemoveDeadBranch(LPCITEMIDLIST pidl);
  334. HRESULT CreateNewFolder(HTREEITEM hti);
  335. BOOL MoveItemsIntoFolder(HWND hwndParent);
  336. HRESULT DoImportOrExport(BOOL fImport);
  337. HRESULT DoSubscriptionForSelection(BOOL fCreate);
  338. LRESULT _OnNotify(LPNMHDR pnm);
  339. HRESULT _OnPaletteChanged(WPARAM wPAram, LPARAM lParam);
  340. HRESULT _OnWindowCleanup(void);
  341. HRESULT _HandleWinIniChange(void);
  342. HRESULT _EnterNewFolderEditMode(LPCITEMIDLIST pidlNewFolder);
  343. HTREEITEM _AddItemToTree(HTREEITEM htiParent, LPITEMIDLIST pidl, int cChildren, int iPos,
  344. HTREEITEM htiAfter = TVI_LAST, BOOL fCheckForDups = TRUE, BOOL fMarked = FALSE);
  345. HTREEITEM _FindChild(IShellFolder *psf, HTREEITEM htiParent, LPCITEMIDLIST pidlChild);
  346. LPITEMIDLIST _GetFullIDList(HTREEITEM hti);
  347. ITEMINFO *_GetTreeItemInfo(HTREEITEM hti);
  348. PORDERITEM _GetTreeOrderItem(HTREEITEM hti);
  349. BOOL _SetRoot(LPCITEMIDLIST pidlRoot, int iExpandDepth, LPCITEMIDLIST pidlExpandTo, NSSR_FLAGS flags);
  350. DWORD _SetStyle(DWORD dwStyle);
  351. DWORD _SetExStyle(DWORD dwExStyle);
  352. void _OnGetInfoTip(NMTVGETINFOTIP *pnm);
  353. LRESULT _OnSetCursor(NMMOUSE* pnm);
  354. void _ApplyCmd(HTREEITEM hti, IContextMenu *pcm, UINT cmdId);
  355. HRESULT _QuerySelection(IContextMenu **ppcm, HTREEITEM *phti);
  356. HMENU _CreateContextMenu(IContextMenu *pcm, HTREEITEM hti);
  357. LRESULT _OnContextMenu(short x, short y);
  358. void _OnBeginDrag(NM_TREEVIEW *pnmhdr);
  359. void _OnChangeNotify(LONG lEvent, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra);
  360. HRESULT _OnDeleteItem(NM_TREEVIEW *pnm);
  361. void _OnGetDisplayInfo(TV_DISPINFO *pnm);
  362. HRESULT _ChangePidlRoot(LPCITEMIDLIST pidl);
  363. BOOL _IsExpandable(HTREEITEM hti);
  364. BOOL _OnItemExpandingMsg(NM_TREEVIEW *pnm);
  365. BOOL _OnItemExpanding(HTREEITEM htiToActivate, UINT action, BOOL fExpandedOnce, BOOL fIsExpandPartial);
  366. BOOL _OnSelChange(BOOL fMark);
  367. void _OnSetSelection();
  368. BOOL _FIsItem(IShellFolder * psf, LPCITEMIDLIST pidlTarget, HTREEITEM hti);
  369. HTREEITEM _FindFromRoot(HTREEITEM htiRoot, LPCITEMIDLIST pidl);
  370. HRESULT _OnSHNotifyRename(LPCITEMIDLIST pidl, LPCITEMIDLIST pidlNew);
  371. HRESULT _OnSHNotifyDelete(LPCITEMIDLIST pidl, int *piPosDeleted, HTREEITEM *phtiParent);
  372. void _OnSHNotifyUpdateItem(LPCITEMIDLIST pidl, LPITEMIDLIST pidlReal);
  373. HRESULT _OnSHNotifyUpdateDir(LPCITEMIDLIST pidl);
  374. HRESULT _OnSHNotifyCreate(LPCITEMIDLIST pidl, int iPosition, HTREEITEM htiParent);
  375. void _OnSHNotifyOnlineChange(HTREEITEM htiRoot, BOOL fGoingOnline);
  376. void _OnSHNotifyCacheChange(HTREEITEM htiRoot, DWORD_PTR dwChanged);
  377. HRESULT _IdlRealFromIdlSimple(IShellFolder * psf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST * ppidlReal);
  378. void _DtRevoke();
  379. void _DtRegister();
  380. int _TreeItemIndexInHDPA(HDPA hdpa, IShellFolder *psfParent, HTREEITEM hti, int iReverseStart);
  381. BOOL _IsItemExpanded(HTREEITEM hti);
  382. HRESULT _UpdateDir(HTREEITEM hti, BOOL bUpdatePidls);
  383. HRESULT _GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, LPSHELLDETAILS pdetails);
  384. HRESULT _ParentFromItem(LPCITEMIDLIST pidl, IShellFolder** ppsfParent, LPCITEMIDLIST *ppidlChild);
  385. HRESULT _CompareIDs(IShellFolder *psf, LPITEMIDLIST pidl1, LPITEMIDLIST pidl2);
  386. static int CALLBACK _TreeCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  387. static LRESULT CALLBACK s_SubClassTreeWndProc(
  388. HWND hwnd, UINT uMsg,
  389. WPARAM wParam, LPARAM lParam,
  390. UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
  391. LRESULT _SubClassTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  392. void _InitHeaderInfo();
  393. HRESULT _Expand(LPCITEMIDLIST pidl, int iDepth);
  394. HTREEITEM _ExpandToItem(LPCITEMIDLIST pidl, BOOL fCreate = TRUE, BOOL fReinsert = FALSE);
  395. HRESULT _ExpandNode(HTREEITEM htiParent, int iCode, int iDepth);
  396. HRESULT _PutRootVariant(VARIANT *pvar);
  397. BOOL _IsItemNameInTree(LPCITEMIDLIST pidl);
  398. COLORREF _GetRegColor(COLORREF clrDefault, LPCTSTR pszName);
  399. void _AssignPidl(PORDERITEM poi, LPITEMIDLIST pidlNew);
  400. protected:
  401. // used for background thread icon + draw info extraction
  402. static void s_NscIconCallback(CNscTree *pns, UINT_PTR uId, int iIcon, int iOpenIcon, DWORD dwFlags, UINT uMagic);
  403. static void s_NscOverlayCallback(CNscTree *pns, UINT_PTR uId, int iOverlayIndex, UINT uMagic);
  404. // used for background enumeration
  405. static void s_NscEnumCallback(CNscTree *pns, LPITEMIDLIST pidl, UINT_PTR uId, DWORD dwSig, HDPA hdpa,
  406. LPITEMIDLIST pidlExpandingTo, DWORD dwOrderSig,
  407. UINT uDepth, BOOL fUpdate, BOOL fUpdatePidls);
  408. private:
  409. void _EnumBackgroundDone(NSC_BKGDENUMDONEDATA *pbedd);
  410. #ifdef DEBUG
  411. void TraceHTREE(HTREEITEM hti, LPCTSTR pszDebugMsg);
  412. void TracePIDL(LPCITEMIDLIST pidl, LPCTSTR pszDebugMsg);
  413. void TracePIDLAbs(LPCITEMIDLIST pidl, LPCTSTR pszDebugMsg);
  414. #endif
  415. static int CALLBACK _TreeOrder(LPARAM lParam1, LPARAM lParam2
  416. , LPARAM lParamSort);
  417. BOOL _IsOrdered(HTREEITEM htiRoot);
  418. void _SelectPidl(LPCITEMIDLIST pidl, BOOL fCreate, BOOL fReinsert = FALSE);
  419. void _SelectNoExpand(HWND hwnd, HTREEITEM hti);
  420. HRESULT _InsertChild(HTREEITEM htiParent, IShellFolder *psfParent, LPCITEMIDLIST pidlChild, BOOL fExpand, BOOL fSimpleToRealIDL, int iPosition, HTREEITEM *phti);
  421. LRESULT _OnCommand(WPARAM wParam, LPARAM lParam);
  422. IStream *GetOrderStream(LPCITEMIDLIST pidl, DWORD grfMode);
  423. HRESULT _PopulateOrderList(HTREEITEM htiRoot);
  424. void _FreeOrderList(HTREEITEM htiRoot);
  425. void _Dropped(void);
  426. LRESULT _OnCDNotify(LPNMCUSTOMDRAW pnm);
  427. BOOL _IsTopParentItem(HTREEITEM hti);
  428. BOOL _MoveNode(int _iDragSrc, int iNewPos, LPITEMIDLIST pidl);
  429. void _TreeInvalidateItemInfo(HTREEITEM hItem, UINT mask);
  430. void _InvalidateImageIndex(HTREEITEM hItem, int iImage);
  431. void _DrawItem(HTREEITEM hti, TCHAR * psz, HDC hdc, LPRECT prc,
  432. DWORD dwFlags, int iLevel, COLORREF clrbk, COLORREF clrtxt);
  433. void _DrawIcon(HTREEITEM hti,HDC hdc, int iLevel, RECT *prc, DWORD dwFlags);
  434. void _UpdateActiveBorder(HTREEITEM htiSelected);
  435. void _MarkChildren(HTREEITEM htiParent, BOOL fOn);
  436. BOOL _IsMarked(HTREEITEM hti);
  437. void _UpdateItemDisplayInfo(HTREEITEM hti);
  438. void _TreeSetItemState(HTREEITEM hti, UINT stateMask, UINT state);
  439. void _TreeNukeCutState();
  440. BOOL _IsChannelFolder(HTREEITEM hti);
  441. BOOL _LoadOrder(HTREEITEM hti, LPCITEMIDLIST pidl, IShellFolder* psf, HDPA* phdpa);
  442. HWND _hwndParent; // parent window to notify
  443. HWND _hwndTree; // tree or combo box
  444. HWND _hwndNextViewer;
  445. HWND _hwndHdr;
  446. DWORD _style;
  447. DWORD _dwExStyle;
  448. DWORD _grfFlags; // Flags to filter what goes in the tree.
  449. DWORD _dwFlags; // Behavior Flags (NSS_*)
  450. DWORD _dwTVFlags;
  451. BITBOOL _fInitialized : 1; // Has INSCTree::Initialize() been called at least once yet?
  452. BITBOOL _fIsSelectionCached: 1; // If the WM_NCDESTROY has been processed, then we squired the selected pidl(s) in _pidlSelected
  453. BITBOOL _fCacheIsDesktop : 1; // state flags
  454. BITBOOL _fAutoExpanding : 1; // tree is auto-expanding
  455. BITBOOL _fDTRegistered:1; // have we registered as droptarget?
  456. BITBOOL _fpsfCacheIsTopLevel : 1; // is the cached psf a root channel ?
  457. BITBOOL _fDragging : 1; // one o items being dragged
  458. BITBOOL _fStartingDrag : 1; // starting to drag an item
  459. BITBOOL _fDropping : 1; // a drop occurred in the nsc
  460. BITBOOL _fInSelectPidl : 1; // we are performing a SelectPidl
  461. BITBOOL _fInserting : 1; // we're on the insertion edge.
  462. BITBOOL _fInsertBefore : 1; // a drop occurred in the nsc
  463. BITBOOL _fClosing : 1; // are we closing ?
  464. BITBOOL _fOkToRename : 1; // are we right clicking.
  465. BITBOOL _fInLabelEdit:1;
  466. BITBOOL _fCollapsing:1; // is a node collapsing.
  467. BITBOOL _fOnline:1; // is inet online?
  468. BITBOOL _fWeChangedOrder:1; // did we change the order?
  469. BITBOOL _fHandlingShellNotification:1; //are we handing a shell notification?
  470. BITBOOL _fSingleExpand:1; // are we in single expand mode
  471. BITBOOL _fHasFocus:1; // does nsc have the focus?
  472. BITBOOL _fIgnoreNextSelChange:1;// hack to get around treeview keydown bug
  473. BITBOOL _fIgnoreNextItemExpanding:1; //hack to get around annoying single expand behavior
  474. BITBOOL _fInExpand:1; // TRUE while we are doing delayed expansion (called back from the secondary thread)
  475. BITBOOL _fSubClassed:1; // Have we subclassed the window yet?
  476. BITBOOL _fAsyncDrop:1; // async drop from outside or another inside folder.
  477. BITBOOL _fOrdered:1; // is root folder ordered.
  478. BITBOOL _fExpandNavigateTo:1; // Do we need to expand when the right pane navigation comes back?
  479. BITBOOL _fNavigationFinished:1; // TRUE when the right hand pane has finished its navigation
  480. BITBOOL _fSelectFromMouseClick:1; // Did we use the mouse to select the item? (as opposed to the keyboard)
  481. BITBOOL _fShouldShowAppStartCursor:1; // TRUE to show the appstart cursor while there is a background task going
  482. BOOL _fUpdate; // true if we are enumerating so that we can update the tree (refresh)
  483. int _cxOldWidth;
  484. UINT _mode;
  485. UINT _csidl;
  486. IContextMenu* _pcm; // context menu currently being displayed
  487. IContextMenu2* _pcmSendTo; // deal with send to hack so messages tgo right place.
  488. LPITEMIDLIST _pidlRoot;
  489. LPITEMIDLIST _pidlSelected; // Valid if _fIsSelectionCached is true. Used for INSCTree::GetSelectedItem() after tree is gone.
  490. HTREEITEM _htiCache; // tree item associated with Current shell folder
  491. IShellFolder* _psfCache; // cache of the last IShellFolder I needed...
  492. IShellFolder2* _psf2Cache; // IShellDetails2 for _psfISD2Cache
  493. IFolderFilter* _pFilter;
  494. INamespaceProxy* _pnscProxy;
  495. ULONG _ulDisplayCol; // Default display col for _psfCache
  496. ULONG _ulSortCol; // Default sort col for _psfCache
  497. ULONG _nChangeNotifyID; // SHChangeNotify registration ID
  498. HDPA _hdpaOrd; // dpa order for current shell folder.
  499. // drop target privates
  500. HTREEITEM _htiCur; // current tree item (dragging over)
  501. DWORD _dwLastTime;
  502. DWORD _dwEffectCur; // current drag effect
  503. int _iDragSrc; // dragging from this pos.
  504. int _iDragDest; // destination drag point
  505. HTREEITEM _htiDropInsert; // parent of inserted item.
  506. HTREEITEM _htiDragging; // the tree item being dragged during D&D.
  507. HTREEITEM _htiCut; // Used for Clipboard and Visuals
  508. LPITEMIDLIST _pidlDrag; // pidl of item being dragged from within.
  509. HTREEITEM _htiFolderStart; // what folder do we start in.
  510. HICON _hicoPinned; // drawn over items that are sticky in the inet cache
  511. HWND _hwndDD; // window to draw custom drag cursors on.
  512. HTREEITEM _htiActiveBorder; // the folder to draw the active border around
  513. CWinInetNotify _inetNotify; // hooks up wininet notifications (online/offline, etc)
  514. IShellTaskScheduler* _pTaskScheduler; // background task icon/info extracter
  515. int _iDefaultFavoriteIcon; // index of default favorite icon in system image list
  516. int _iDefaultFolderIcon; // index of default folder icon in system image list
  517. HTREEITEM _htiRenaming; // hti of item being renamed in rename mode
  518. LPITEMIDLIST _pidlNewFolderParent; // where the new folder will be arriving (when user picks "Create New Folder")
  519. DWORD _dwSignature; // Signature used to track items in the tree, even after they've moved
  520. DWORD _dwOrderSig; // Signature that lets us detect changes in ordering of items
  521. BYTE _bSynchId; // magic number for validating tree during background icon extraction
  522. HDPA _hdpaColumns; // visible columns when NSS_HEADER is set
  523. HDPA _hdpaViews; // ishellfolderviewtype view pidls
  524. LPITEMIDLIST _pidlExpandingTo; // During expansion of the tree, this is the pidl of the item we want to reach.
  525. LPITEMIDLIST _pidlNavigatingTo; // This is the pidl to which the right pane is currently navigating to
  526. UINT _uDepth; // depth of recursive expansion
  527. CRITICAL_SECTION _csBackgroundData; // protects the data from the background tasks.
  528. NSC_BKGDENUMDONEDATA * _pbeddList; // List of tasks that are done.
  529. BITBOOL _fShowCompColor:1; // Show compressed files in different color
  530. enum
  531. {
  532. RSVIDM_CONTEXT_START = RSVIDM_LAST + 1, // our private menu items end here
  533. };
  534. };
  535. int DPADeleteItemCB(void *pItem, void *pData);
  536. int DPADeletePidlsCB(void *pItem, void *pData);
  537. // util macros.
  538. #define GetPoi(p) (((ITEMINFO *)p)->poi)
  539. #define GetPii(p) ((ITEMINFO *)p)
  540. #include "nscband.h"
  541. #endif // _NSC_C