2 * ExplorerBrowser Control implementation.
4 * Copyright 2010 David Hedberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
31 #include "wine/list.h"
32 #include "wine/debug.h"
35 #include "shell32_main.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(shell);
40 #define SPLITTER_WIDTH 2
41 #define NP_MIN_WIDTH 60
42 #define SV_MIN_WIDTH 150
44 typedef struct _event_client {
46 IExplorerBrowserEvents *pebe;
50 typedef struct _travellog_entry {
55 typedef struct _ExplorerBrowserImpl {
56 IExplorerBrowser IExplorerBrowser_iface;
57 IShellBrowser IShellBrowser_iface;
58 ICommDlgBrowser3 ICommDlgBrowser3_iface;
59 IObjectWithSite IObjectWithSite_iface;
60 INameSpaceTreeControlEvents INameSpaceTreeControlEvents_iface;
61 IInputObject IInputObject_iface;
70 INameSpaceTreeControl2 *pnstc2;
71 HWND hwnd_splitter, hwnd_nstc;
78 EXPLORER_BROWSER_OPTIONS eb_options;
81 struct list event_clients;
82 DWORD events_next_cookie;
83 struct list travellog;
84 travellog_entry *travellog_cursor;
89 LPITEMIDLIST current_pidl;
92 ICommDlgBrowser *pcdb_site;
93 ICommDlgBrowser2 *pcdb2_site;
94 ICommDlgBrowser3 *pcdb3_site;
95 IExplorerPaneVisibility *pepv_site;
96 } ExplorerBrowserImpl;
98 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc);
100 /**************************************************************************
103 static void events_unadvise_all(ExplorerBrowserImpl *This)
105 event_client *client, *curs;
108 LIST_FOR_EACH_ENTRY_SAFE(client, curs, &This->event_clients, event_client, entry)
110 TRACE("Removing %p\n", client);
111 list_remove(&client->entry);
112 IExplorerBrowserEvents_Release(client->pebe);
113 HeapFree(GetProcessHeap(), 0, client);
117 static HRESULT events_NavigationPending(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
119 event_client *cursor;
124 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
126 TRACE("Notifying %p\n", cursor);
127 hres = IExplorerBrowserEvents_OnNavigationPending(cursor->pebe, pidl);
129 /* If this failed for any reason, the browsing is supposed to be aborted. */
137 static void events_NavigationComplete(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
139 event_client *cursor;
143 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
145 TRACE("Notifying %p\n", cursor);
146 IExplorerBrowserEvents_OnNavigationComplete(cursor->pebe, pidl);
150 static void events_NavigationFailed(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
152 event_client *cursor;
156 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
158 TRACE("Notifying %p\n", cursor);
159 IExplorerBrowserEvents_OnNavigationFailed(cursor->pebe, pidl);
163 static void events_ViewCreated(ExplorerBrowserImpl *This, IShellView *psv)
165 event_client *cursor;
169 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
171 TRACE("Notifying %p\n", cursor);
172 IExplorerBrowserEvents_OnViewCreated(cursor->pebe, psv);
176 /**************************************************************************
177 * Travellog functions.
179 static void travellog_remove_entry(ExplorerBrowserImpl *This, travellog_entry *entry)
181 TRACE("Removing %p\n", entry);
183 list_remove(&entry->entry);
185 HeapFree(GetProcessHeap(), 0, entry);
186 This->travellog_count--;
189 static void travellog_remove_all_entries(ExplorerBrowserImpl *This)
191 travellog_entry *cursor, *cursor2;
194 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
195 travellog_remove_entry(This, cursor);
197 This->travellog_cursor = NULL;
200 static void travellog_add_entry(ExplorerBrowserImpl *This, LPITEMIDLIST pidl)
202 travellog_entry *new, *cursor, *cursor2;
203 TRACE("%p (old count %d)\n", pidl, This->travellog_count);
205 /* Replace the old tail, if any, with the new entry */
206 if(This->travellog_cursor)
208 LIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, &This->travellog, travellog_entry, entry)
210 if(cursor == This->travellog_cursor)
212 travellog_remove_entry(This, cursor);
216 /* Create and add the new entry */
217 new = HeapAlloc(GetProcessHeap(), 0, sizeof(travellog_entry));
218 new->pidl = ILClone(pidl);
219 list_add_tail(&This->travellog, &new->entry);
220 This->travellog_cursor = new;
221 This->travellog_count++;
223 /* Remove the first few entries if the size limit is reached. */
224 if(This->travellog_count > 200)
227 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
231 travellog_remove_entry(This, cursor);
236 static LPCITEMIDLIST travellog_go_back(ExplorerBrowserImpl *This)
238 travellog_entry *prev;
239 TRACE("%p, %p\n", This, This->travellog_cursor);
241 if(!This->travellog_cursor)
244 prev = LIST_ENTRY(list_prev(&This->travellog, &This->travellog_cursor->entry),
245 travellog_entry, entry);
249 This->travellog_cursor = prev;
253 static LPCITEMIDLIST travellog_go_forward(ExplorerBrowserImpl *This)
255 travellog_entry *next;
256 TRACE("%p, %p\n", This, This->travellog_cursor);
258 if(!This->travellog_cursor)
261 next = LIST_ENTRY(list_next(&This->travellog, &This->travellog_cursor->entry),
262 travellog_entry, entry);
266 This->travellog_cursor = next;
270 /**************************************************************************
273 static void update_layout(ExplorerBrowserImpl *This)
276 INT navpane_width_actual;
277 INT shellview_width_actual;
278 TRACE("%p (navpane: %d, EBO_SHOWFRAMES: %d)\n",
279 This, This->navpane.show, This->eb_options & EBO_SHOWFRAMES);
281 GetClientRect(This->hwnd_main, &rc);
283 if((This->eb_options & EBO_SHOWFRAMES) && This->navpane.show)
284 navpane_width_actual = This->navpane.width;
286 navpane_width_actual = 0;
288 shellview_width_actual = rc.right - navpane_width_actual;
289 if(shellview_width_actual < SV_MIN_WIDTH && navpane_width_actual)
291 INT missing_width = SV_MIN_WIDTH - shellview_width_actual;
292 if(missing_width < (navpane_width_actual - NP_MIN_WIDTH))
294 /* Shrink the navpane */
295 navpane_width_actual -= missing_width;
296 shellview_width_actual += missing_width;
300 /* Hide the navpane */
301 shellview_width_actual += navpane_width_actual;
302 navpane_width_actual = 0;
306 /**************************************************************
307 * Calculate rectangles for the panes. All rectangles contain
308 * the position of the panes relative to hwnd_main.
311 if(navpane_width_actual)
313 This->navpane.rc.left = This->navpane.rc.top = 0;
314 This->navpane.rc.right = navpane_width_actual;
315 This->navpane.rc.bottom = rc.bottom;
317 if(!This->navpane.hwnd_splitter)
318 initialize_navpane(This, This->hwnd_main, &This->navpane.rc);
321 ZeroMemory(&This->navpane.rc, sizeof(RECT));
323 This->sv_rc.left = navpane_width_actual;
325 This->sv_rc.right = This->sv_rc.left + shellview_width_actual;
326 This->sv_rc.bottom = rc.bottom;
329 static void size_panes(ExplorerBrowserImpl *This)
331 MoveWindow(This->navpane.hwnd_splitter,
332 This->navpane.rc.right - SPLITTER_WIDTH, This->navpane.rc.top,
333 SPLITTER_WIDTH, This->navpane.rc.bottom - This->navpane.rc.top,
336 MoveWindow(This->hwnd_sv,
337 This->sv_rc.left, This->sv_rc.top,
338 This->sv_rc.right - This->sv_rc.left, This->sv_rc.bottom - This->sv_rc.top,
342 static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
350 hr = IShellView_QueryInterface(This->psv, &IID_IFolderView, (void*)&pfv);
353 hr = IFolderView_SetCurrentViewMode(pfv, This->fs.ViewMode);
354 IFolderView_Release(pfv);
360 static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi)
362 IShellBrowser *psb = &This->IShellBrowser_iface;
368 TRACE("%p, %p\n", This, psi);
370 hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFObject, &IID_IShellFolder, (void**)&psf);
373 hr = IShellFolder_CreateViewObject(psf, This->hwnd_main, &IID_IShellView, (void**)&psv);
378 IShellView_DestroyViewWindow(This->psv);
379 This->hwnd_sv = NULL;
382 hr = IShellView_CreateViewWindow(psv, This->psv, &This->fs, psb, &This->sv_rc, &hwnd_new);
385 /* Replace the old shellview */
386 if(This->psv) IShellView_Release(This->psv);
389 This->hwnd_sv = hwnd_new;
390 events_ViewCreated(This, psv);
394 ERR("CreateViewWindow failed (0x%x)\n", hr);
395 IShellView_Release(psv);
399 ERR("CreateViewObject failed (0x%x)\n", hr);
401 IShellFolder_Release(psf);
404 ERR("SI::BindToHandler failed (0x%x)\n", hr);
409 static void get_interfaces_from_site(ExplorerBrowserImpl *This)
411 IServiceProvider *psp;
414 /* Calling this with This->punk_site set to NULL should properly
415 * release any previously fetched interfaces.
420 IUnknown_Release(This->pcdb_site);
421 if(This->pcdb2_site) IUnknown_Release(This->pcdb2_site);
422 if(This->pcdb3_site) IUnknown_Release(This->pcdb3_site);
424 This->pcdb_site = NULL;
425 This->pcdb2_site = NULL;
426 This->pcdb3_site = NULL;
431 IExplorerPaneVisibility_Release(This->pepv_site);
432 This->pepv_site = NULL;
438 hr = IUnknown_QueryInterface(This->punk_site, &IID_IServiceProvider, (void**)&psp);
441 ERR("Failed to get IServiceProvider from site.\n");
445 /* ICommDlgBrowser */
446 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser,
447 (void**)&This->pcdb_site);
448 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2,
449 (void**)&This->pcdb2_site);
450 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3,
451 (void**)&This->pcdb3_site);
453 /* IExplorerPaneVisibility */
454 IServiceProvider_QueryService(psp, &SID_ExplorerPaneVisibility, &IID_IExplorerPaneVisibility,
455 (void**)&This->pepv_site);
457 IServiceProvider_Release(psp);
460 /**************************************************************************
461 * General pane functionality.
463 static void update_panestate(ExplorerBrowserImpl *This)
465 EXPLORERPANESTATE eps = EPS_DONTCARE;
469 if(!This->pepv_site) return;
471 IExplorerPaneVisibility_GetPaneState(This->pepv_site, (REFEXPLORERPANE) &EP_NavPane, &eps);
472 if( !(eps & EPS_DEFAULT_OFF) )
475 show_navpane = FALSE;
477 if(This->navpane.show != show_navpane)
483 This->navpane.show = show_navpane;
486 static void splitter_draw(HWND hwnd, RECT *rc)
488 HDC hdc = GetDC(hwnd);
490 ReleaseDC(hwnd, hdc);
493 /**************************************************************************
494 * The Navigation Pane.
496 static LRESULT navpane_splitter_beginresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
502 CopyRect(&This->splitter_rc, &This->navpane.rc);
503 This->splitter_rc.left = This->splitter_rc.right - SPLITTER_WIDTH;
505 splitter_draw(GetParent(hwnd), &This->splitter_rc);
510 static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
515 if(GetCapture() != hwnd) return FALSE;
517 dx = (SHORT)LOWORD(lParam);
520 CopyRect(&rc, &This->navpane.rc);
522 new_width = This->navpane.width + dx;
523 if(new_width > NP_MIN_WIDTH && This->sv_rc.right - new_width > SV_MIN_WIDTH)
525 rc.right = new_width;
526 rc.left = rc.right - SPLITTER_WIDTH;
527 splitter_draw(GetParent(hwnd), &This->splitter_rc);
528 splitter_draw(GetParent(hwnd), &rc);
529 CopyRect(&This->splitter_rc, &rc);
535 static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
539 if(GetCapture() != hwnd) return FALSE;
541 dx = (SHORT)LOWORD(lParam);
544 splitter_draw(GetParent(hwnd), &This->splitter_rc);
546 new_width = This->navpane.width + dx;
547 if(new_width < NP_MIN_WIDTH)
548 new_width = NP_MIN_WIDTH;
549 else if(This->sv_rc.right - new_width < SV_MIN_WIDTH)
550 new_width = This->sv_rc.right - SV_MIN_WIDTH;
552 This->navpane.width = new_width;
562 static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
564 ExplorerBrowserImpl *This = crs->lpCreateParams;
565 INameSpaceTreeControl2 *pnstc2;
570 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LPARAM)This);
571 This->navpane.hwnd_splitter = hwnd;
573 hr = CoCreateInstance(&CLSID_NamespaceTreeControl, NULL, CLSCTX_INPROC_SERVER,
574 &IID_INameSpaceTreeControl2, (void**)&pnstc2);
578 style = NSTCS_HASEXPANDOS | NSTCS_ROOTHASEXPANDO | NSTCS_SHOWSELECTIONALWAYS;
579 hr = INameSpaceTreeControl2_Initialize(pnstc2, GetParent(hwnd), NULL, style);
582 INameSpaceTreeControlEvents *pnstce;
583 IShellFolder *psfdesktop;
587 DWORD cookie, style2 = NSTCS2_DISPLAYPADDING;
589 hr = INameSpaceTreeControl2_SetControlStyle2(pnstc2, 0xFF, style2);
591 ERR("SetControlStyle2 failed (0x%08x)\n", hr);
593 hr = INameSpaceTreeControl2_QueryInterface(pnstc2, &IID_IOleWindow, (void**)&pow);
596 IOleWindow_GetWindow(pow, &This->navpane.hwnd_nstc);
597 IOleWindow_Release(pow);
600 ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr);
602 pnstce = &This->INameSpaceTreeControlEvents_iface;
603 hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie);
605 ERR("TreeAdvise failed. (0x%08x).\n", hr);
608 * Add the default roots
611 /* TODO: This should be FOLDERID_Links */
612 hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
615 hr = SHCreateShellItem(NULL, NULL, pidl, &psi);
618 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_NONFOLDERS, NSTCRS_VISIBLE, NULL);
619 IShellItem_Release(psi);
624 SHGetDesktopFolder(&psfdesktop);
625 hr = SHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
626 IShellFolder_Release(psfdesktop);
629 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_FOLDERS, NSTCRS_EXPANDED, NULL);
630 IShellItem_Release(psi);
634 * We should advertise IID_INameSpaceTreeControl to the site of the
635 * host through its IProfferService interface, if any.
638 This->navpane.pnstc2 = pnstc2;
639 This->navpane.nstc_cookie = cookie;
645 This->navpane.pnstc2 = NULL;
646 ERR("Failed (0x%08x)\n", hr);
651 static LRESULT navpane_on_wm_size_move(ExplorerBrowserImpl *This)
656 width = This->navpane.rc.right - This->navpane.rc.left - SPLITTER_WIDTH;
657 height = This->navpane.rc.bottom - This->navpane.rc.top;
659 MoveWindow(This->navpane.hwnd_nstc,
660 This->navpane.rc.left, This->navpane.rc.top,
667 static LRESULT navpane_on_wm_destroy(ExplorerBrowserImpl *This)
669 INameSpaceTreeControl_TreeUnadvise(This->navpane.pnstc2, This->navpane.nstc_cookie);
670 INameSpaceTreeControl_Release(This->navpane.pnstc2);
671 This->navpane.pnstc2 = NULL;
675 static LRESULT CALLBACK navpane_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
677 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
680 case WM_CREATE: return navpane_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
681 case WM_MOVE: /* Fall through */
682 case WM_SIZE: return navpane_on_wm_size_move(This);
683 case WM_DESTROY: return navpane_on_wm_destroy(This);
684 case WM_LBUTTONDOWN: return navpane_splitter_beginresize(This, hWnd, lParam);
685 case WM_MOUSEMOVE: return navpane_splitter_resizing(This, hWnd, lParam);
686 case WM_LBUTTONUP: return navpane_splitter_endresize(This, hWnd, lParam);
688 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
693 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc)
697 static const WCHAR navpane_classname[] = {'e','b','_','n','a','v','p','a','n','e',0};
699 if( !GetClassInfoW(shell32_hInstance, navpane_classname, &wc) )
701 wc.style = CS_HREDRAW | CS_VREDRAW;
702 wc.lpfnWndProc = navpane_wndproc;
705 wc.hInstance = shell32_hInstance;
707 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_SIZEWE);
708 wc.hbrBackground = (HBRUSH)(COLOR_HIGHLIGHT + 1);
709 wc.lpszMenuName = NULL;
710 wc.lpszClassName = navpane_classname;
712 if (!RegisterClassW(&wc)) return;
715 splitter = CreateWindowExW(0, navpane_classname, NULL,
716 WS_CHILD | WS_TABSTOP | WS_VISIBLE,
717 rc->right - SPLITTER_WIDTH, rc->top,
718 SPLITTER_WIDTH, rc->bottom - rc->top,
719 hwnd_parent, 0, shell32_hInstance, This);
721 ERR("Failed to create navpane : %d.\n", GetLastError());
724 /**************************************************************************
725 * Main window related functions.
727 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
729 ExplorerBrowserImpl *This = crs->lpCreateParams;
732 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
733 This->hwnd_main = hWnd;
738 static LRESULT main_on_wm_size(ExplorerBrowserImpl *This)
746 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
748 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
752 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
753 case WM_SIZE: return main_on_wm_size(This);
754 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
760 /**************************************************************************
761 * IExplorerBrowser Implementation
764 static inline ExplorerBrowserImpl *impl_from_IExplorerBrowser(IExplorerBrowser *iface)
766 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IExplorerBrowser_iface);
769 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
770 REFIID riid, void **ppvObject)
772 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
773 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
776 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
777 IsEqualIID(riid, &IID_IUnknown))
781 else if(IsEqualIID(riid, &IID_IShellBrowser))
783 *ppvObject = &This->IShellBrowser_iface;
785 else if(IsEqualIID(riid, &IID_ICommDlgBrowser) ||
786 IsEqualIID(riid, &IID_ICommDlgBrowser2) ||
787 IsEqualIID(riid, &IID_ICommDlgBrowser3))
789 *ppvObject = &This->ICommDlgBrowser3_iface;
791 else if(IsEqualIID(riid, &IID_IObjectWithSite))
793 *ppvObject = &This->IObjectWithSite_iface;
795 else if(IsEqualIID(riid, &IID_IInputObject))
797 *ppvObject = &This->IInputObject_iface;
802 IUnknown_AddRef((IUnknown*)*ppvObject);
806 return E_NOINTERFACE;
809 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
811 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
812 LONG ref = InterlockedIncrement(&This->ref);
813 TRACE("%p - ref %d\n", This, ref);
818 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
820 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
821 LONG ref = InterlockedDecrement(&This->ref);
822 TRACE("%p - ref %d\n", This, ref);
829 IExplorerBrowser_Destroy(iface);
831 IObjectWithSite_SetSite(&This->IObjectWithSite_iface, NULL);
833 HeapFree(GetProcessHeap(), 0, This);
840 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
841 HWND hwndParent, const RECT *prc,
842 const FOLDERSETTINGS *pfs)
844 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
847 static const WCHAR EB_CLASS_NAME[] =
848 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
850 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
858 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
860 wc.style = CS_HREDRAW | CS_VREDRAW;
861 wc.lpfnWndProc = main_wndproc;
864 wc.hInstance = shell32_hInstance;
866 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
867 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
868 wc.lpszMenuName = NULL;
869 wc.lpszClassName = EB_CLASS_NAME;
871 if (!RegisterClassW(&wc)) return E_FAIL;
874 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
875 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
877 prc->right - prc->left, prc->bottom - prc->top,
878 hwndParent, 0, shell32_hInstance, This);
882 ERR("Failed to create the window.\n");
886 This->fs.ViewMode = pfs ? pfs->ViewMode : FVM_DETAILS;
887 This->fs.fFlags = pfs ? (pfs->fFlags | FWF_NOCLIENTEDGE) : FWF_NOCLIENTEDGE;
892 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
894 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
899 IShellView_DestroyViewWindow(This->psv);
900 IShellView_Release(This->psv);
902 This->hwnd_sv = NULL;
905 events_unadvise_all(This);
906 travellog_remove_all_entries(This);
908 ILFree(This->current_pidl);
909 This->current_pidl = NULL;
911 DestroyWindow(This->hwnd_main);
912 This->destroyed = TRUE;
917 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
918 HDWP *phdwp, RECT rcBrowser)
920 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
921 TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
925 *phdwp = DeferWindowPos(*phdwp, This->hwnd_main, NULL, rcBrowser.left, rcBrowser.top,
926 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top,
927 SWP_NOZORDER | SWP_NOACTIVATE);
933 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
934 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
940 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
941 LPCWSTR pszPropertyBag)
943 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
944 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
949 /* FIXME: This method is currently useless as we don't save any
950 * settings anywhere, but at least one application breaks if we
957 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
958 LPCWSTR pszEmptyText)
960 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
961 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
966 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
967 const FOLDERSETTINGS *pfs)
969 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
970 TRACE("%p (%p)\n", This, pfs);
975 This->fs.ViewMode = pfs->ViewMode;
976 This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
978 /* Change the settings of the current view, if any. */
979 return change_viewmode(This, This->fs.ViewMode);
982 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
983 IExplorerBrowserEvents *psbe,
986 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
987 event_client *client;
988 TRACE("%p (%p, %p)\n", This, psbe, pdwCookie);
990 client = HeapAlloc(GetProcessHeap(), 0, sizeof(event_client));
992 client->cookie = ++This->events_next_cookie;
994 IExplorerBrowserEvents_AddRef(psbe);
995 *pdwCookie = client->cookie;
997 list_add_tail(&This->event_clients, &client->entry);
1002 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
1005 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1006 event_client *client;
1007 TRACE("%p (0x%x)\n", This, dwCookie);
1009 LIST_FOR_EACH_ENTRY(client, &This->event_clients, event_client, entry)
1011 if(client->cookie == dwCookie)
1013 list_remove(&client->entry);
1014 IExplorerBrowserEvents_Release(client->pebe);
1015 HeapFree(GetProcessHeap(), 0, client);
1020 return E_INVALIDARG;
1023 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
1024 EXPLORER_BROWSER_OPTIONS dwFlag)
1026 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1027 static const EXPLORER_BROWSER_OPTIONS unsupported_options =
1028 EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW;
1030 TRACE("%p (0x%x)\n", This, dwFlag);
1032 if(dwFlag & unsupported_options)
1033 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag);
1035 This->eb_options = dwFlag;
1040 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
1041 EXPLORER_BROWSER_OPTIONS *pdwFlag)
1043 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1044 TRACE("%p (%p)\n", This, pdwFlag);
1046 *pdwFlag = This->eb_options;
1051 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
1052 PCUIDLIST_RELATIVE pidl,
1055 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1056 LPITEMIDLIST absolute_pidl = NULL;
1058 static const UINT unsupported_browse_flags =
1059 SBSP_NEWBROWSER | EBF_SELECTFROMDATAOBJECT | EBF_NODROPTARGET;
1060 TRACE("%p (%p, 0x%x)\n", This, pidl, uFlags);
1062 if(!This->hwnd_main)
1066 return HRESULT_FROM_WIN32(ERROR_BUSY);
1068 if(This->current_pidl && (This->eb_options & EBO_NAVIGATEONCE))
1071 if(uFlags & SBSP_EXPLOREMODE)
1072 return E_INVALIDARG;
1074 if(uFlags & unsupported_browse_flags)
1075 FIXME("Argument 0x%x contains unsupported flags.\n", uFlags);
1077 if(uFlags & SBSP_NAVIGATEBACK)
1079 TRACE("SBSP_NAVIGATEBACK\n");
1080 absolute_pidl = ILClone(travellog_go_back(This));
1081 if(!absolute_pidl && !This->current_pidl)
1083 else if(!absolute_pidl)
1087 else if(uFlags & SBSP_NAVIGATEFORWARD)
1089 TRACE("SBSP_NAVIGATEFORWARD\n");
1090 absolute_pidl = ILClone(travellog_go_forward(This));
1091 if(!absolute_pidl && !This->current_pidl)
1093 else if(!absolute_pidl)
1097 else if(uFlags & SBSP_PARENT)
1099 if(This->current_pidl)
1101 if(_ILIsPidlSimple(This->current_pidl))
1103 absolute_pidl = _ILCreateDesktop();
1107 absolute_pidl = ILClone(This->current_pidl);
1108 ILRemoveLastID(absolute_pidl);
1113 ERR("Failed to get parent pidl.\n");
1118 else if(uFlags & SBSP_RELATIVE)
1120 /* SBSP_RELATIVE has precedence over SBSP_ABSOLUTE */
1121 TRACE("SBSP_RELATIVE\n");
1122 if(This->current_pidl)
1124 absolute_pidl = ILCombine(This->current_pidl, pidl);
1128 ERR("Failed to get absolute pidl.\n");
1134 TRACE("SBSP_ABSOLUTE\n");
1135 absolute_pidl = ILClone(pidl);
1136 if(!absolute_pidl && !This->current_pidl)
1137 return E_INVALIDARG;
1138 else if(!absolute_pidl)
1142 /* TODO: Asynchronous browsing. Return S_OK here and finish in
1143 * another thread. */
1145 hr = events_NavigationPending(This, absolute_pidl);
1148 TRACE("Browsing aborted.\n");
1149 ILFree(absolute_pidl);
1153 get_interfaces_from_site(This);
1154 update_panestate(This);
1156 /* Only browse if the new pidl differs from the old */
1157 if(!ILIsEqual(This->current_pidl, absolute_pidl))
1160 hr = SHCreateItemFromIDList(absolute_pidl, &IID_IShellItem, (void**)&psi);
1163 hr = create_new_shellview(This, psi);
1166 events_NavigationFailed(This, absolute_pidl);
1167 ILFree(absolute_pidl);
1168 IShellItem_Release(psi);
1172 /* Add to travellog */
1173 if( !(This->eb_options & EBO_NOTRAVELLOG) &&
1174 !(uFlags & (SBSP_NAVIGATEFORWARD|SBSP_NAVIGATEBACK)) )
1176 travellog_add_entry(This, absolute_pidl);
1179 IShellItem_Release(psi);
1183 events_NavigationComplete(This, absolute_pidl);
1184 ILFree(This->current_pidl);
1185 This->current_pidl = absolute_pidl;
1187 /* Expand the NameSpaceTree to the current location. */
1188 if(This->navpane.show && This->navpane.pnstc2)
1191 hr = SHCreateItemFromIDList(This->current_pidl, &IID_IShellItem, (void**)&psi);
1194 INameSpaceTreeControl_EnsureItemVisible(This->navpane.pnstc2, psi);
1195 IShellItem_Release(psi);
1202 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
1203 IUnknown *punk, UINT uFlags)
1205 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1208 TRACE("%p (%p, 0x%x)\n", This, punk, uFlags);
1211 return IExplorerBrowser_fnBrowseToIDList(iface, NULL, uFlags);
1213 hr = SHGetIDListFromObject(punk, &pidl);
1216 hr = IExplorerBrowser_BrowseToIDList(iface, pidl, uFlags);
1223 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
1225 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
1227 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1228 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
1233 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
1235 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1236 FIXME("stub, %p\n", This);
1241 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
1242 REFIID riid, void **ppv)
1244 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1245 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
1250 return IShellView_QueryInterface(This->psv, riid, ppv);
1253 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
1255 IExplorerBrowser_fnQueryInterface,
1256 IExplorerBrowser_fnAddRef,
1257 IExplorerBrowser_fnRelease,
1258 IExplorerBrowser_fnInitialize,
1259 IExplorerBrowser_fnDestroy,
1260 IExplorerBrowser_fnSetRect,
1261 IExplorerBrowser_fnSetPropertyBag,
1262 IExplorerBrowser_fnSetEmptyText,
1263 IExplorerBrowser_fnSetFolderSettings,
1264 IExplorerBrowser_fnAdvise,
1265 IExplorerBrowser_fnUnadvise,
1266 IExplorerBrowser_fnSetOptions,
1267 IExplorerBrowser_fnGetOptions,
1268 IExplorerBrowser_fnBrowseToIDList,
1269 IExplorerBrowser_fnBrowseToObject,
1270 IExplorerBrowser_fnFillFromObject,
1271 IExplorerBrowser_fnRemoveAll,
1272 IExplorerBrowser_fnGetCurrentView
1275 /**************************************************************************
1276 * IShellBrowser Implementation
1279 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
1281 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IShellBrowser_iface);
1284 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
1285 REFIID riid, void **ppvObject)
1287 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1288 TRACE("%p\n", This);
1289 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
1292 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
1294 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1295 TRACE("%p\n", This);
1296 return IUnknown_AddRef((IUnknown*) This);
1299 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
1301 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1302 TRACE("%p\n", This);
1303 return IUnknown_Release((IUnknown*) This);
1306 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
1308 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1309 TRACE("%p (%p)\n", This, phwnd);
1311 if(!This->hwnd_main)
1314 *phwnd = This->hwnd_main;
1318 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
1321 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1322 FIXME("stub, %p (%d)\n", This, fEnterMode);
1327 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
1329 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1331 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1332 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
1334 /* Not implemented. */
1338 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
1340 HOLEMENU holemenuReserved,
1341 HWND hwndActiveObject)
1343 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1344 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
1346 /* Not implemented. */
1350 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
1353 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1354 TRACE("%p (%p)\n", This, hmenuShared);
1356 /* Not implemented. */
1360 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
1361 LPCOLESTR pszStatusText)
1363 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1364 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
1369 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
1372 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1373 FIXME("stub, %p (%d)\n", This, fEnable);
1378 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
1379 MSG *pmsg, WORD wID)
1381 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1382 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
1387 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
1388 LPCITEMIDLIST pidl, UINT wFlags)
1390 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1391 TRACE("%p (%p, %x)\n", This, pidl, wFlags);
1393 return IExplorerBrowser_fnBrowseToIDList((IExplorerBrowser*)This, pidl, wFlags);
1396 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
1400 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1401 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
1407 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
1408 UINT id, HWND *phwnd)
1410 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1411 TRACE("%p (%d, %p)\n", This, id, phwnd);
1413 /* Not implemented. */
1417 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
1419 WPARAM wParam, LPARAM lParam,
1422 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1423 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
1428 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
1431 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1432 TRACE("%p (%p)\n", This, ppshv);
1438 IShellView_AddRef(This->psv);
1443 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
1446 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1447 FIXME("stub, %p (%p)\n", This, pshv);
1452 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
1453 LPTBBUTTONSB lpButtons,
1454 UINT nButtons, UINT uFlags)
1456 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1457 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
1462 static const IShellBrowserVtbl vt_IShellBrowser = {
1463 IShellBrowser_fnQueryInterface,
1464 IShellBrowser_fnAddRef,
1465 IShellBrowser_fnRelease,
1466 IShellBrowser_fnGetWindow,
1467 IShellBrowser_fnContextSensitiveHelp,
1468 IShellBrowser_fnInsertMenusSB,
1469 IShellBrowser_fnSetMenuSB,
1470 IShellBrowser_fnRemoveMenusSB,
1471 IShellBrowser_fnSetStatusTextSB,
1472 IShellBrowser_fnEnableModelessSB,
1473 IShellBrowser_fnTranslateAcceleratorSB,
1474 IShellBrowser_fnBrowseObject,
1475 IShellBrowser_fnGetViewStateStream,
1476 IShellBrowser_fnGetControlWindow,
1477 IShellBrowser_fnSendControlMsg,
1478 IShellBrowser_fnQueryActiveShellView,
1479 IShellBrowser_fnOnViewWindowActive,
1480 IShellBrowser_fnSetToolbarItems
1483 /**************************************************************************
1484 * ICommDlgBrowser3 Implementation
1487 static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
1489 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, ICommDlgBrowser3_iface);
1492 static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface,
1496 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1497 TRACE("%p\n", This);
1498 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
1501 static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
1503 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1504 TRACE("%p\n", This);
1505 return IUnknown_AddRef((IUnknown*) This);
1508 static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
1510 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1511 TRACE("%p\n", This);
1512 return IUnknown_Release((IUnknown*) This);
1515 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *iface,
1518 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1521 HRESULT ret = S_FALSE;
1523 TRACE("%p (%p)\n", This, shv);
1525 hr = IShellView_GetItemObject(shv, SVGIO_SELECTION, &IID_IDataObject, (void**)&pdo);
1531 fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
1533 fmt.dwAspect = DVASPECT_CONTENT;
1535 fmt.tymed = TYMED_HGLOBAL;
1537 hr = IDataObject_GetData(pdo, &fmt ,&medium);
1538 IDataObject_Release(pdo);
1541 LPIDA pida = GlobalLock(medium.u.hGlobal);
1542 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
1544 /* Handle folders by browsing to them. */
1545 if(_ILIsFolder(pidl_child) || _ILIsDrive(pidl_child) || _ILIsSpecialFolder(pidl_child))
1547 IExplorerBrowser_BrowseToIDList((IExplorerBrowser*)This, pidl_child, SBSP_RELATIVE);
1550 GlobalUnlock(medium.u.hGlobal);
1551 GlobalFree(medium.u.hGlobal);
1554 ERR("Failed to get data from IDataObject.\n");
1556 ERR("Failed to get IDataObject.\n");
1558 /* If we didn't handle the default command, check if we have a
1559 * client that does */
1560 if(ret == S_FALSE && This->pcdb_site)
1561 return ICommDlgBrowser_OnDefaultCommand(This->pcdb_site, shv);
1565 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface,
1566 IShellView *shv, ULONG uChange)
1568 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1569 TRACE("%p (%p, %d)\n", This, shv, uChange);
1572 return ICommDlgBrowser_OnStateChange(This->pcdb_site, shv, uChange);
1576 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
1577 IShellView *pshv, LPCITEMIDLIST pidl)
1579 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1580 TRACE("%p (%p, %p)\n", This, pshv, pidl);
1583 return ICommDlgBrowser_IncludeObject(This->pcdb_site, pshv, pidl);
1588 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
1592 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1593 TRACE("%p (%p, 0x%x)\n", This, pshv, dwNotifyType);
1595 if(This->pcdb2_site)
1596 return ICommDlgBrowser2_Notify(This->pcdb2_site, pshv, dwNotifyType);
1601 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(ICommDlgBrowser3 *iface,
1603 LPWSTR pszText, int cchMax)
1605 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1606 TRACE("%p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
1608 if(This->pcdb2_site)
1609 return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb2_site, pshv, pszText, cchMax);
1614 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(ICommDlgBrowser3 *iface,
1617 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1618 TRACE("%p (%p)\n", This, pdwFlags);
1620 if(This->pcdb2_site)
1621 return ICommDlgBrowser2_GetViewFlags(This->pcdb2_site, pdwFlags);
1626 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(ICommDlgBrowser3 *iface,
1627 IShellView *pshv, int iColumn)
1629 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1630 TRACE("%p (%p, %d)\n", This, pshv, iColumn);
1632 if(This->pcdb3_site)
1633 return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
1638 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(ICommDlgBrowser3 *iface,
1642 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1643 TRACE("%p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
1645 if(This->pcdb3_site)
1646 return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
1651 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(ICommDlgBrowser3 *iface,
1654 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1655 TRACE("%p (%p)\n", This, pshv);
1657 if(This->pcdb3_site)
1658 return ICommDlgBrowser3_OnPreviewCreated(This->pcdb3_site, pshv);
1663 static const ICommDlgBrowser3Vtbl vt_ICommDlgBrowser3 = {
1664 ICommDlgBrowser3_fnQueryInterface,
1665 ICommDlgBrowser3_fnAddRef,
1666 ICommDlgBrowser3_fnRelease,
1667 ICommDlgBrowser3_fnOnDefaultCommand,
1668 ICommDlgBrowser3_fnOnStateChange,
1669 ICommDlgBrowser3_fnIncludeObject,
1670 ICommDlgBrowser3_fnNotify,
1671 ICommDlgBrowser3_fnGetDefaultMenuText,
1672 ICommDlgBrowser3_fnGetViewFlags,
1673 ICommDlgBrowser3_fnOnColumnClicked,
1674 ICommDlgBrowser3_fnGetCurrentFilter,
1675 ICommDlgBrowser3_fnOnPreviewCreated
1678 /**************************************************************************
1679 * IObjectWithSite Implementation
1682 static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
1684 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IObjectWithSite_iface);
1687 static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface,
1688 REFIID riid, void **ppvObject)
1690 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1691 TRACE("%p\n", This);
1692 return IUnknown_QueryInterface((IUnknown*)This, riid, ppvObject);
1695 static ULONG WINAPI IObjectWithSite_fnAddRef(IObjectWithSite *iface)
1697 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1698 TRACE("%p\n", This);
1699 return IUnknown_AddRef((IUnknown*)This);
1702 static ULONG WINAPI IObjectWithSite_fnRelease(IObjectWithSite *iface)
1704 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1705 TRACE("%p\n", This);
1706 return IUnknown_Release((IUnknown*)This);
1709 static HRESULT WINAPI IObjectWithSite_fnSetSite(IObjectWithSite *iface, IUnknown *punk_site)
1711 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1712 TRACE("%p (%p)\n", This, punk_site);
1716 IUnknown_Release(This->punk_site);
1717 This->punk_site = NULL;
1718 get_interfaces_from_site(This);
1721 This->punk_site = punk_site;
1724 IUnknown_AddRef(This->punk_site);
1729 static HRESULT WINAPI IObjectWithSite_fnGetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite)
1731 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1732 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvSite);
1734 if(!This->punk_site)
1737 return IUnknown_QueryInterface(This->punk_site, riid, ppvSite);
1740 static const IObjectWithSiteVtbl vt_IObjectWithSite = {
1741 IObjectWithSite_fnQueryInterface,
1742 IObjectWithSite_fnAddRef,
1743 IObjectWithSite_fnRelease,
1744 IObjectWithSite_fnSetSite,
1745 IObjectWithSite_fnGetSite
1748 /**************************************************************************
1749 * INameSpaceTreeControlEvents Implementation
1751 static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
1753 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, INameSpaceTreeControlEvents_iface);
1756 static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface,
1757 REFIID riid, void **ppvObject)
1759 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1760 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
1763 if(IsEqualIID(riid, &IID_INameSpaceTreeControlEvents) ||
1764 IsEqualIID(riid, &IID_IUnknown))
1771 IUnknown_AddRef((IUnknown*)*ppvObject);
1775 return E_NOINTERFACE;
1778 static ULONG WINAPI NSTCEvents_fnAddRef(INameSpaceTreeControlEvents *iface)
1780 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1781 TRACE("%p\n", This);
1782 return IUnknown_AddRef((IUnknown*)This);
1785 static ULONG WINAPI NSTCEvents_fnRelease(INameSpaceTreeControlEvents *iface)
1787 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1788 TRACE("%p\n", This);
1789 return IUnknown_Release((IUnknown*)This);
1792 static HRESULT WINAPI NSTCEvents_fnOnItemClick(INameSpaceTreeControlEvents *iface,
1794 NSTCEHITTEST nstceHitTest,
1795 NSTCECLICKTYPE nstceClickType)
1797 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1798 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstceHitTest, nstceClickType);
1802 static HRESULT WINAPI NSTCEvents_fnOnPropertyItemCommit(INameSpaceTreeControlEvents *iface,
1805 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1806 TRACE("%p (%p)\n", This, psi);
1810 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanging(INameSpaceTreeControlEvents *iface,
1812 NSTCITEMSTATE nstcisMask,
1813 NSTCITEMSTATE nstcisState)
1815 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1816 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1820 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanged(INameSpaceTreeControlEvents *iface,
1822 NSTCITEMSTATE nstcisMask,
1823 NSTCITEMSTATE nstcisState)
1825 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1826 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1830 static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(INameSpaceTreeControlEvents *iface,
1831 IShellItemArray *psiaSelection)
1833 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1836 TRACE("%p (%p)\n", This, psiaSelection);
1838 hr = IShellItemArray_GetItemAt(psiaSelection, 0, &psi);
1841 hr = IExplorerBrowser_BrowseToObject((IExplorerBrowser*)This,
1842 (IUnknown*)psi, SBSP_DEFBROWSER);
1843 IShellItem_Release(psi);
1849 static HRESULT WINAPI NSTCEvents_fnOnKeyboardInput(INameSpaceTreeControlEvents *iface,
1850 UINT uMsg, WPARAM wParam, LPARAM lParam)
1852 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1853 TRACE("%p (%d, 0x%lx, 0x%lx)\n", This, uMsg, wParam, lParam);
1857 static HRESULT WINAPI NSTCEvents_fnOnBeforeExpand(INameSpaceTreeControlEvents *iface,
1860 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1861 TRACE("%p (%p)\n", This, psi);
1865 static HRESULT WINAPI NSTCEvents_fnOnAfterExpand(INameSpaceTreeControlEvents *iface,
1868 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1869 TRACE("%p (%p)\n", This, psi);
1873 static HRESULT WINAPI NSTCEvents_fnOnBeginLabelEdit(INameSpaceTreeControlEvents *iface,
1876 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1877 TRACE("%p (%p)\n", This, psi);
1881 static HRESULT WINAPI NSTCEvents_fnOnEndLabelEdit(INameSpaceTreeControlEvents *iface,
1884 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1885 TRACE("%p (%p)\n", This, psi);
1889 static HRESULT WINAPI NSTCEvents_fnOnGetToolTip(INameSpaceTreeControlEvents *iface,
1890 IShellItem *psi, LPWSTR pszTip, int cchTip)
1892 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1893 TRACE("%p (%p, %p, %d)\n", This, psi, pszTip, cchTip);
1897 static HRESULT WINAPI NSTCEvents_fnOnBeforeItemDelete(INameSpaceTreeControlEvents *iface,
1900 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1901 TRACE("%p (%p)\n", This, psi);
1905 static HRESULT WINAPI NSTCEvents_fnOnItemAdded(INameSpaceTreeControlEvents *iface,
1906 IShellItem *psi, BOOL fIsRoot)
1908 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1909 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1913 static HRESULT WINAPI NSTCEvents_fnOnItemDeleted(INameSpaceTreeControlEvents *iface,
1914 IShellItem *psi, BOOL fIsRoot)
1916 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1917 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1921 static HRESULT WINAPI NSTCEvents_fnOnBeforeContextMenu(INameSpaceTreeControlEvents *iface,
1922 IShellItem *psi, REFIID riid, void **ppv)
1924 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1925 TRACE("%p (%p, %s, %p)\n", This, psi, shdebugstr_guid(riid), ppv);
1929 static HRESULT WINAPI NSTCEvents_fnOnAfterContextMenu(INameSpaceTreeControlEvents *iface,
1930 IShellItem *psi, IContextMenu *pcmIn,
1931 REFIID riid, void **ppv)
1933 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1934 TRACE("%p (%p, %p, %s, %p)\n", This, psi, pcmIn, shdebugstr_guid(riid), ppv);
1938 static HRESULT WINAPI NSTCEvents_fnOnBeforeStateImageChange(INameSpaceTreeControlEvents *iface,
1941 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1942 TRACE("%p (%p)\n", This, psi);
1946 static HRESULT WINAPI NSTCEvents_fnOnGetDefaultIconIndex(INameSpaceTreeControlEvents* iface,
1948 int *piDefaultIcon, int *piOpenIcon)
1950 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1951 TRACE("%p (%p, %p, %p)\n", This, psi, piDefaultIcon, piOpenIcon);
1956 static const INameSpaceTreeControlEventsVtbl vt_INameSpaceTreeControlEvents = {
1957 NSTCEvents_fnQueryInterface,
1958 NSTCEvents_fnAddRef,
1959 NSTCEvents_fnRelease,
1960 NSTCEvents_fnOnItemClick,
1961 NSTCEvents_fnOnPropertyItemCommit,
1962 NSTCEvents_fnOnItemStateChanging,
1963 NSTCEvents_fnOnItemStateChanged,
1964 NSTCEvents_fnOnSelectionChanged,
1965 NSTCEvents_fnOnKeyboardInput,
1966 NSTCEvents_fnOnBeforeExpand,
1967 NSTCEvents_fnOnAfterExpand,
1968 NSTCEvents_fnOnBeginLabelEdit,
1969 NSTCEvents_fnOnEndLabelEdit,
1970 NSTCEvents_fnOnGetToolTip,
1971 NSTCEvents_fnOnBeforeItemDelete,
1972 NSTCEvents_fnOnItemAdded,
1973 NSTCEvents_fnOnItemDeleted,
1974 NSTCEvents_fnOnBeforeContextMenu,
1975 NSTCEvents_fnOnAfterContextMenu,
1976 NSTCEvents_fnOnBeforeStateImageChange,
1977 NSTCEvents_fnOnGetDefaultIconIndex
1980 /**************************************************************************
1981 * IInputObject Implementation
1984 static inline ExplorerBrowserImpl *impl_from_IInputObject(IInputObject *iface)
1986 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IInputObject_iface);
1989 static HRESULT WINAPI IInputObject_fnQueryInterface(IInputObject *iface,
1990 REFIID riid, void **ppvObject)
1992 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
1993 TRACE("%p\n", This);
1994 return IUnknown_QueryInterface((IUnknown*)This, riid, ppvObject);
1997 static ULONG WINAPI IInputObject_fnAddRef(IInputObject *iface)
1999 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2000 TRACE("%p\n", This);
2001 return IUnknown_AddRef((IUnknown*)This);
2004 static ULONG WINAPI IInputObject_fnRelease(IInputObject *iface)
2006 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2007 TRACE("%p\n", This);
2008 return IUnknown_Release((IUnknown*)This);
2011 static HRESULT WINAPI IInputObject_fnUIActivateIO(IInputObject *iface, BOOL fActivate, MSG *pMsg)
2013 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2014 FIXME("stub, %p (%d, %p)\n", This, fActivate, pMsg);
2018 static HRESULT WINAPI IInputObject_fnHasFocusIO(IInputObject *iface)
2020 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2021 FIXME("stub, %p\n", This);
2025 static HRESULT WINAPI IInputObject_fnTranslateAcceleratorIO(IInputObject *iface, MSG *pMsg)
2027 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2028 FIXME("stub, %p (%p)\n", This, pMsg);
2032 static IInputObjectVtbl vt_IInputObject = {
2033 IInputObject_fnQueryInterface,
2034 IInputObject_fnAddRef,
2035 IInputObject_fnRelease,
2036 IInputObject_fnUIActivateIO,
2037 IInputObject_fnHasFocusIO,
2038 IInputObject_fnTranslateAcceleratorIO
2041 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
2043 ExplorerBrowserImpl *eb;
2046 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
2051 return CLASS_E_NOAGGREGATION;
2053 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
2055 eb->IExplorerBrowser_iface.lpVtbl = &vt_IExplorerBrowser;
2056 eb->IShellBrowser_iface.lpVtbl = &vt_IShellBrowser;
2057 eb->ICommDlgBrowser3_iface.lpVtbl = &vt_ICommDlgBrowser3;
2058 eb->IObjectWithSite_iface.lpVtbl = &vt_IObjectWithSite;
2059 eb->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_INameSpaceTreeControlEvents;
2060 eb->IInputObject_iface.lpVtbl = &vt_IInputObject;
2062 /* Default settings */
2063 eb->navpane.width = 150;
2064 eb->navpane.show = TRUE;
2066 list_init(&eb->event_clients);
2067 list_init(&eb->travellog);
2069 ret = IExplorerBrowser_QueryInterface((IExplorerBrowser*)eb, riid, ppv);
2070 IExplorerBrowser_Release((IExplorerBrowser*)eb);
2072 TRACE("--(%p)\n", ppv);