ReactOS 0.4.16-dev-122-g325d74c
CExplorerBand Class Reference

#include <CExplorerBand.h>

Inheritance diagram for CExplorerBand:
Collaboration diagram for CExplorerBand:

Public Member Functions

 CExplorerBand ()
 
virtual ~CExplorerBand ()
 
STDMETHODIMP GetClassID (CLSID *pClassID) override
 
STDMETHODIMP OnSelectionChanged (_In_ PCIDLIST_ABSOLUTE pidl) override
 
STDMETHODIMP Invoke (_In_ PCIDLIST_ABSOLUTE pidl) override
 
STDMETHODIMP GetTypeInfoCount (UINT *pctinfo) override
 
STDMETHODIMP GetTypeInfo (UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) override
 
STDMETHODIMP GetIDsOfNames (REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) override
 
STDMETHODIMP Invoke (DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IDispatch
HRESULT GetTypeInfoCount ([out] UINT *pctinfo)
 
HRESULT GetTypeInfo ([in] UINT iTInfo, [in] LCID lcid, [out] ITypeInfo **ppTInfo)
 
HRESULT GetIDsOfNames ([in] REFIID riid, [in, size_is(cNames)] LPOLESTR *rgszNames, [in] UINT cNames, [in] LCID lcid, [out, size_is(cNames)] DISPID *rgDispId)
 
HRESULT Invoke ([in] DISPID dispIdMember, [in] REFIID riid, [in] LCID lcid, [in] WORD wFlags, [in, out] DISPPARAMS *pDispParams, [out] VARIANT *pVarResult, [out] EXCEPINFO *pExcepInfo, [out] UINT *puArgErr)
 
HRESULT RemoteInvoke ([in] DISPID dispIdMember, [in] REFIID riid, [in] LCID lcid, [in] DWORD dwFlags, [in] DISPPARAMS *pDispParams, [out] VARIANT *pVarResult, [out] EXCEPINFO *pExcepInfo, [out] UINT *pArgErr, [in] UINT cVarRef, [in, size_is(cVarRef)] UINT *rgVarRefIdx, [in, out, size_is(cVarRef)] VARIANTARG *rgVarRef)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Protected Member Functions

INT _GetRootCsidl () override
 
DWORD _GetTVStyle () override
 
DWORD _GetTVExStyle () override
 
DWORD _GetEnumFlags () override
 
HRESULT _CreateTreeView (HWND hwndParent) override
 
void _DestroyTreeView () override
 
BOOL _WantsRootItem () override
 
BOOL _GetTitle (LPWSTR pszTitle, INT cchTitle) override
 
void _SortItems (HTREEITEM hParent) override
 
BOOL _NavigateToCurrentFolder ()
 
BOOL _NavigateToPIDL (_In_ LPCITEMIDLIST dest, _Out_ HTREEITEM *phItem, _In_ BOOL bExpand, _In_ BOOL bInsert, _In_ BOOL bSelect)
 

Static Protected Member Functions

static INT CALLBACK _CompareTreeItems (LPARAM p1, LPARAM p2, LPARAM p3)
 

Additional Inherited Members

- Public Types inherited from IDispatch
typedef IDispatchLPDISPATCH
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from IDispatch
const DISPID DISPID_UNKNOWN = -1
 
const DISPID DISPID_VALUE = 0
 
const DISPID DISPID_PROPERTYPUT = -3
 
const DISPID DISPID_NEWENUM = -4
 
const DISPID DISPID_EVALUATE = -5
 
const DISPID DISPID_CONSTRUCTOR = -6
 
const DISPID DISPID_DESTRUCTOR = -7
 
const DISPID DISPID_COLLECT = -8
 

Detailed Description

Definition at line 13 of file CExplorerBand.h.

Constructor & Destructor Documentation

◆ CExplorerBand()

CExplorerBand::CExplorerBand ( )

Definition at line 21 of file CExplorerBand.cpp.

22{
23}

◆ ~CExplorerBand()

CExplorerBand::~CExplorerBand ( )
virtual

Definition at line 25 of file CExplorerBand.cpp.

26{
27}

Member Function Documentation

◆ _CompareTreeItems()

INT CALLBACK CExplorerBand::_CompareTreeItems ( LPARAM  p1,
LPARAM  p2,
LPARAM  p3 
)
staticprotected

Definition at line 96 of file CExplorerBand.cpp.

97{
98 CItemData *info1 = (CItemData*)p1;
99 CItemData *info2 = (CItemData*)p2;
100 IShellFolder *pDesktop = (IShellFolder *)p3;
101 HRESULT hr = pDesktop->CompareIDs(0, info1->absolutePidl, info2->absolutePidl);
102 if (FAILED(hr))
103 return 0;
104 return (SHORT)HRESULT_CODE(hr);
105}
HRESULT CompareIDs([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)
#define FAILED(hr)
Definition: intsafe.h:51
short SHORT
Definition: pedump.c:59
HRESULT hr
Definition: shlfolder.c:183
#define HRESULT_CODE(hr)
Definition: winerror.h:76

Referenced by _SortItems().

◆ _CreateTreeView()

HRESULT CExplorerBand::_CreateTreeView ( HWND  hwndParent)
overrideprotected

Definition at line 107 of file CExplorerBand.cpp.

108{
109 HRESULT hr = CNSCBand::_CreateTreeView(hwndParent);
111 return hr;
112
113 // Insert the root node
114 m_hRoot = _InsertItem(NULL, m_pDesktop, m_pidlRoot, m_pidlRoot, FALSE);
115 if (!m_hRoot)
116 {
117 ERR("Failed to create root item\n");
118 return E_FAIL;
119 }
120 TreeView_Expand(m_hwndTreeView, m_hRoot, TVE_EXPAND);
121
122 // Navigate to current folder position
124
125 // Register browser connection endpoint
126 CComPtr<IWebBrowser2> browserService;
127 hr = IUnknown_QueryService(m_pSite, SID_SWebBrowserApp, IID_PPV_ARG(IWebBrowser2, &browserService));
129 return hr;
130
131 // Communicate via IDispatch
132 hr = AtlAdvise(browserService, dynamic_cast<IDispatch*>(this), DIID_DWebBrowserEvents, &m_adviseCookie);
134 return hr;
135
136 return hr;
137}
#define ERR(fmt,...)
Definition: precomp.h:57
BOOL _NavigateToCurrentFolder()
static HWND hwndParent
Definition: cryptui.c:300
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw)
Definition: atl.c:45
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1501
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3425
#define TVE_EXPAND
Definition: commctrl.h:3428
#define SID_SWebBrowserApp
Definition: shlguid.h:111
#define IID_PPV_ARG(Itype, ppType)

◆ _DestroyTreeView()

void CExplorerBand::_DestroyTreeView ( )
overrideprotected

Definition at line 139 of file CExplorerBand.cpp.

140{
141 CComPtr<IWebBrowser2> browserService;
143 IID_PPV_ARG(IWebBrowser2, &browserService));
145 return;
146
147 AtlUnadvise(browserService, DIID_DWebBrowserEvents, m_adviseCookie);
148
149 CNSCBand::_DestroyTreeView();
150}
HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw)
Definition: atl.c:73

◆ _GetEnumFlags()

DWORD CExplorerBand::_GetEnumFlags ( )
overrideprotected

Definition at line 54 of file CExplorerBand.cpp.

55{
56 return SHCONTF_FOLDERS;
57}

◆ _GetRootCsidl()

INT CExplorerBand::_GetRootCsidl ( )
overrideprotected

Definition at line 37 of file CExplorerBand.cpp.

38{
39 return CSIDL_DESKTOP;
40}
#define CSIDL_DESKTOP
Definition: shlobj.h:2173

◆ _GetTitle()

BOOL CExplorerBand::_GetTitle ( LPWSTR  pszTitle,
INT  cchTitle 
)
overrideprotected

Definition at line 59 of file CExplorerBand.cpp.

60{
61 return ::LoadStringW(instance, IDS_FOLDERSLABEL, pszTitle, cchTitle);
62}
static HINSTANCE instance
Definition: main.c:40
#define IDS_FOLDERSLABEL
Definition: resource.h:14

◆ _GetTVExStyle()

DWORD CExplorerBand::_GetTVExStyle ( )
overrideprotected

Definition at line 49 of file CExplorerBand.cpp.

50{
51 return 0;
52}

◆ _GetTVStyle()

DWORD CExplorerBand::_GetTVStyle ( )
overrideprotected

Definition at line 42 of file CExplorerBand.cpp.

43{
44 // Remove TVS_SINGLEEXPAND for now since it has strange behaviour
46 TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_EDITLABELS /* | TVS_SINGLEEXPAND*/;
47}
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define TVS_SHOWSELALWAYS
Definition: commctrl.h:3257
#define TVS_HASLINES
Definition: commctrl.h:3253
#define TVS_HASBUTTONS
Definition: commctrl.h:3252
#define TVS_EDITLABELS
Definition: commctrl.h:3255

◆ _NavigateToCurrentFolder()

BOOL CExplorerBand::_NavigateToCurrentFolder ( )
protected

Definition at line 197 of file CExplorerBand.cpp.

198{
199 CComHeapPtr<ITEMIDLIST> pidl;
200 HRESULT hr = _GetCurrentLocation(&pidl);
202 return FALSE;
203
204 // Find PIDL into our explorer
205 ++m_mtxBlockNavigate;
208 --m_mtxBlockNavigate;
209
210 return result;
211}
BOOL _NavigateToPIDL(_In_ LPCITEMIDLIST dest, _Out_ HTREEITEM *phItem, _In_ BOOL bExpand, _In_ BOOL bInsert, _In_ BOOL bSelect)
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint64EXT * result
Definition: glext.h:11304
HTREEITEM hItem
Definition: treelist.h:37

Referenced by _CreateTreeView(), and Invoke().

◆ _NavigateToPIDL()

BOOL CExplorerBand::_NavigateToPIDL ( _In_ LPCITEMIDLIST  dest,
_Out_ HTREEITEM phItem,
_In_ BOOL  bExpand,
_In_ BOOL  bInsert,
_In_ BOOL  bSelect 
)
protected

Navigate to a given PIDL in the treeview, and return matching tree item handle

  • dest: The absolute PIDL we should navigate in the treeview
  • item: Handle of the tree item matching the PIDL
  • bExpand: expand collapsed nodes in order to find the right element
  • bInsert: insert the element at the right place if we don't find it
  • bSelect: select the item after we found it

Definition at line 222 of file CExplorerBand.cpp.

228{
229 if (!phItem)
230 return FALSE;
231
232 *phItem = NULL;
233
234 HTREEITEM hItem = TreeView_GetFirstVisible(m_hwndTreeView);
235 HTREEITEM hParent = NULL, tmp;
236 while (TRUE)
237 {
238 CItemData *pItemData = GetItemData(hItem);
239 if (!pItemData)
240 {
241 ERR("Something has gone wrong, no data associated to node\n");
242 return FALSE;
243 }
244
245 // If we found our node, give it back
246 if (!m_pDesktop->CompareIDs(0, pItemData->absolutePidl, dest))
247 {
248 if (bSelect)
249 TreeView_SelectItem(m_hwndTreeView, hItem);
250 *phItem = hItem;
251 return TRUE;
252 }
253
254 // Check if we are a parent of the requested item
255 TVITEMW tvItem;
256 LPITEMIDLIST relativeChild = ILFindChild(pItemData->absolutePidl, dest);
257 if (relativeChild)
258 {
259 // Notify treeview we have children
260 tvItem.mask = TVIF_CHILDREN;
261 tvItem.hItem = hItem;
262 tvItem.cChildren = 1;
263 TreeView_SetItem(m_hwndTreeView, &tvItem);
264
265 // If we can expand and the node isn't expanded yet, do it
266 if (bExpand)
267 {
268 if (!pItemData->expanded)
269 {
270 _InsertSubitems(hItem, pItemData->absolutePidl);
271 pItemData->expanded = TRUE;
272 }
273 TreeView_Expand(m_hwndTreeView, hItem, TVE_EXPAND);
274 }
275
276 // Try to get a child
277 tmp = TreeView_GetChild(m_hwndTreeView, hItem);
278 if (tmp)
279 {
280 // We have a child, let's continue with it
281 hParent = hItem;
282 hItem = tmp;
283 continue;
284 }
285
286 if (bInsert && pItemData->expanded)
287 {
288 // Happens when we have to create a subchild inside a child
289 hItem = _InsertItem(hItem, dest, relativeChild, TRUE);
290 }
291
292 // We end up here, without any children, so we found nothing
293 // Tell the parent node it has children
294 ZeroMemory(&tvItem, sizeof(tvItem));
295 return FALSE;
296 }
297
298 // Find sibling
299 tmp = TreeView_GetNextSibling(m_hwndTreeView, hItem);
300 if (tmp)
301 {
302 hItem = tmp;
303 continue;
304 }
305
306 if (bInsert)
307 {
308 *phItem = hItem = _InsertItem(hParent, dest, ILFindLastID(dest), TRUE);
309 return TRUE;
310 }
311
312 return FALSE;
313 }
314
316}
static BOOL bInsert
Definition: cmdinput.c:121
static char * dest
Definition: rtl.c:135
#define UNREACHABLE
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198
PUIDLIST_RELATIVE WINAPI ILFindChild(PIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2)
Definition: pidl.c:660
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3486
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3471
#define TreeView_GetFirstVisible(hwnd)
Definition: commctrl.h:3475
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3472
#define TVIF_CHILDREN
Definition: commctrl.h:3277
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3502
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
HTREEITEM hItem
Definition: commctrl.h:3322
UINT mask
Definition: commctrl.h:3321
int cChildren
Definition: commctrl.h:3329
#define ZeroMemory
Definition: winbase.h:1712

Referenced by _NavigateToCurrentFolder().

◆ _SortItems()

void CExplorerBand::_SortItems ( HTREEITEM  hParent)
overrideprotected

Definition at line 87 of file CExplorerBand.cpp.

88{
89 TVSORTCB sortCallback;
90 sortCallback.hParent = hParent;
91 sortCallback.lpfnCompare = _CompareTreeItems;
92 sortCallback.lParam = (LPARAM)(PVOID)m_pDesktop; // m_pDesktop is not a pointer
93 TreeView_SortChildrenCB(m_hwndTreeView, &sortCallback, 0);
94}
static INT CALLBACK _CompareTreeItems(LPARAM p1, LPARAM p2, LPARAM p3)
#define TreeView_SortChildrenCB(hwnd, psort, recurse)
Definition: commctrl.h:3553
LPARAM lParam
Definition: commctrl.h:3621
HTREEITEM hParent
Definition: commctrl.h:3619
PFNTVCOMPARE lpfnCompare
Definition: commctrl.h:3620
LONG_PTR LPARAM
Definition: windef.h:208

◆ _WantsRootItem()

BOOL CExplorerBand::_WantsRootItem ( )
overrideprotected

Definition at line 64 of file CExplorerBand.cpp.

65{
66 return TRUE;
67}

◆ GetClassID()

STDMETHODIMP CExplorerBand::GetClassID ( CLSID pClassID)
override

Definition at line 29 of file CExplorerBand.cpp.

30{
31 if (!pClassID)
32 return E_POINTER;
33 *pClassID = CLSID_ExplorerBand;
34 return S_OK;
35}
#define S_OK
Definition: intsafe.h:52
#define E_POINTER
Definition: winerror.h:2365

◆ GetIDsOfNames()

STDMETHODIMP CExplorerBand::GetIDsOfNames ( REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
override

Implements IDispatch.

Definition at line 166 of file CExplorerBand.cpp.

167{
169 return E_NOTIMPL;
170}
#define UNIMPLEMENTED
Definition: debug.h:118
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetTypeInfo()

STDMETHODIMP CExplorerBand::GetTypeInfo ( UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
override

Implements IDispatch.

Definition at line 160 of file CExplorerBand.cpp.

161{
163 return E_NOTIMPL;
164}

◆ GetTypeInfoCount()

STDMETHODIMP CExplorerBand::GetTypeInfoCount ( UINT pctinfo)
override

Implements IDispatch.

Definition at line 154 of file CExplorerBand.cpp.

155{
157 return E_NOTIMPL;
158}

◆ Invoke() [1/2]

STDMETHODIMP CExplorerBand::Invoke ( _In_ PCIDLIST_ABSOLUTE  pidl)
override

Definition at line 76 of file CExplorerBand.cpp.

77{
78 /* Prevents navigation if selection is initiated inside the band */
79 if (m_mtxBlockNavigate)
80 return S_OK;
81
82 _UpdateBrowser(pidl);
83 m_hwndTreeView.SetFocus();
84 return S_OK;
85}

Referenced by OnSelectionChanged().

◆ Invoke() [2/2]

STDMETHODIMP CExplorerBand::Invoke ( DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
override

Implements IDispatch.

Definition at line 173 of file CExplorerBand.cpp.

182{
183 switch (dispIdMember)
184 {
187 {
188 TRACE("dispId %d received\n", dispIdMember);
190 return S_OK;
191 }
192 }
193 TRACE("Unknown dispid requested: %08x\n", dispIdMember);
194 return E_INVALIDARG;
195}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define DISPID_NAVIGATECOMPLETE2
Definition: webchild.h:54
#define DISPID_DOWNLOADCOMPLETE
Definition: webchild.h:39

◆ OnSelectionChanged()

STDMETHODIMP CExplorerBand::OnSelectionChanged ( _In_ PCIDLIST_ABSOLUTE  pidl)
override

Definition at line 70 of file CExplorerBand.cpp.

71{
72 return Invoke(pidl);
73}
STDMETHODIMP Invoke(_In_ PCIDLIST_ABSOLUTE pidl) override

The documentation for this class was generated from the following files: