shell32/ebrowser: Use proper color for pane separator.
[wine.git] / dlls / shell32 / ebrowser.c
blobd50a4fc1f99d43ef5b6d0ac2e77b900e660b33e8
1 /*
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
21 #include <stdarg.h>
23 #define COBJMACROS
24 #define NONAMELESSUNION
26 #include "winerror.h"
27 #include "windef.h"
28 #include "winbase.h"
30 #include "wine/list.h"
31 #include "wine/debug.h"
32 #include "debughlp.h"
34 #include "shell32_main.h"
35 #include "pidl.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(shell);
39 #define SPLITTER_WIDTH 2
40 #define NP_MIN_WIDTH 60
41 #define SV_MIN_WIDTH 150
43 typedef struct _event_client {
44 struct list entry;
45 IExplorerBrowserEvents *pebe;
46 DWORD cookie;
47 } event_client;
49 typedef struct _travellog_entry {
50 struct list entry;
51 LPITEMIDLIST pidl;
52 } travellog_entry;
54 typedef struct _ExplorerBrowserImpl {
55 IExplorerBrowser IExplorerBrowser_iface;
56 IShellBrowser IShellBrowser_iface;
57 ICommDlgBrowser3 ICommDlgBrowser3_iface;
58 IObjectWithSite IObjectWithSite_iface;
59 INameSpaceTreeControlEvents INameSpaceTreeControlEvents_iface;
60 IInputObject IInputObject_iface;
61 LONG ref;
62 BOOL destroyed;
64 HWND hwnd_main;
65 HWND hwnd_sv;
67 RECT splitter_rc;
68 struct {
69 INameSpaceTreeControl2 *pnstc2;
70 HWND hwnd_splitter, hwnd_nstc;
71 DWORD nstc_cookie;
72 UINT width;
73 BOOL show;
74 RECT rc;
75 } navpane;
77 EXPLORER_BROWSER_OPTIONS eb_options;
78 FOLDERSETTINGS fs;
80 struct list event_clients;
81 DWORD events_next_cookie;
82 struct list travellog;
83 travellog_entry *travellog_cursor;
84 int travellog_count;
86 IShellView *psv;
87 RECT sv_rc;
88 LPITEMIDLIST current_pidl;
90 IUnknown *punk_site;
91 ICommDlgBrowser *pcdb_site;
92 ICommDlgBrowser2 *pcdb2_site;
93 ICommDlgBrowser3 *pcdb3_site;
94 IExplorerPaneVisibility *pepv_site;
95 } ExplorerBrowserImpl;
97 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc);
99 /**************************************************************************
100 * Event functions.
102 static void events_unadvise_all(ExplorerBrowserImpl *This)
104 event_client *client, *curs;
105 TRACE("%p\n", This);
107 LIST_FOR_EACH_ENTRY_SAFE(client, curs, &This->event_clients, event_client, entry)
109 TRACE("Removing %p\n", client);
110 list_remove(&client->entry);
111 IExplorerBrowserEvents_Release(client->pebe);
112 HeapFree(GetProcessHeap(), 0, client);
116 static HRESULT events_NavigationPending(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
118 event_client *cursor;
119 HRESULT hres = S_OK;
121 TRACE("%p\n", This);
123 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
125 TRACE("Notifying %p\n", cursor);
126 hres = IExplorerBrowserEvents_OnNavigationPending(cursor->pebe, pidl);
128 /* If this failed for any reason, the browsing is supposed to be aborted. */
129 if(FAILED(hres))
130 break;
133 return hres;
136 static void events_NavigationComplete(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
138 event_client *cursor;
140 TRACE("%p\n", This);
142 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
144 TRACE("Notifying %p\n", cursor);
145 IExplorerBrowserEvents_OnNavigationComplete(cursor->pebe, pidl);
149 static void events_NavigationFailed(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
151 event_client *cursor;
153 TRACE("%p\n", This);
155 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
157 TRACE("Notifying %p\n", cursor);
158 IExplorerBrowserEvents_OnNavigationFailed(cursor->pebe, pidl);
162 static void events_ViewCreated(ExplorerBrowserImpl *This, IShellView *psv)
164 event_client *cursor;
166 TRACE("%p\n", This);
168 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
170 TRACE("Notifying %p\n", cursor);
171 IExplorerBrowserEvents_OnViewCreated(cursor->pebe, psv);
175 /**************************************************************************
176 * Travellog functions.
178 static void travellog_remove_entry(ExplorerBrowserImpl *This, travellog_entry *entry)
180 TRACE("Removing %p\n", entry);
182 list_remove(&entry->entry);
183 ILFree(entry->pidl);
184 HeapFree(GetProcessHeap(), 0, entry);
185 This->travellog_count--;
188 static void travellog_remove_all_entries(ExplorerBrowserImpl *This)
190 travellog_entry *cursor, *cursor2;
191 TRACE("%p\n", This);
193 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
194 travellog_remove_entry(This, cursor);
196 This->travellog_cursor = NULL;
199 static void travellog_add_entry(ExplorerBrowserImpl *This, LPITEMIDLIST pidl)
201 travellog_entry *new, *cursor, *cursor2;
202 TRACE("%p (old count %d)\n", pidl, This->travellog_count);
204 /* Replace the old tail, if any, with the new entry */
205 if(This->travellog_cursor)
207 LIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, &This->travellog, travellog_entry, entry)
209 if(cursor == This->travellog_cursor)
210 break;
211 travellog_remove_entry(This, cursor);
215 /* Create and add the new entry */
216 new = HeapAlloc(GetProcessHeap(), 0, sizeof(travellog_entry));
217 new->pidl = ILClone(pidl);
218 list_add_tail(&This->travellog, &new->entry);
219 This->travellog_cursor = new;
220 This->travellog_count++;
222 /* Remove the first few entries if the size limit is reached. */
223 if(This->travellog_count > 200)
225 UINT i = 0;
226 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
228 if(i++ > 10)
229 break;
230 travellog_remove_entry(This, cursor);
235 static LPCITEMIDLIST travellog_go_back(ExplorerBrowserImpl *This)
237 travellog_entry *prev;
238 TRACE("%p, %p\n", This, This->travellog_cursor);
240 if(!This->travellog_cursor)
241 return NULL;
243 prev = LIST_ENTRY(list_prev(&This->travellog, &This->travellog_cursor->entry),
244 travellog_entry, entry);
245 if(!prev)
246 return NULL;
248 This->travellog_cursor = prev;
249 return prev->pidl;
252 static LPCITEMIDLIST travellog_go_forward(ExplorerBrowserImpl *This)
254 travellog_entry *next;
255 TRACE("%p, %p\n", This, This->travellog_cursor);
257 if(!This->travellog_cursor)
258 return NULL;
260 next = LIST_ENTRY(list_next(&This->travellog, &This->travellog_cursor->entry),
261 travellog_entry, entry);
262 if(!next)
263 return NULL;
265 This->travellog_cursor = next;
266 return next->pidl;
269 /**************************************************************************
270 * Helper functions
272 static void update_layout(ExplorerBrowserImpl *This)
274 RECT rc;
275 INT navpane_width_actual;
276 INT shellview_width_actual;
277 TRACE("%p (navpane: %d, EBO_SHOWFRAMES: %d)\n",
278 This, This->navpane.show, This->eb_options & EBO_SHOWFRAMES);
280 GetClientRect(This->hwnd_main, &rc);
282 if((This->eb_options & EBO_SHOWFRAMES) && This->navpane.show)
283 navpane_width_actual = This->navpane.width;
284 else
285 navpane_width_actual = 0;
287 shellview_width_actual = rc.right - navpane_width_actual;
288 if(shellview_width_actual < SV_MIN_WIDTH && navpane_width_actual)
290 INT missing_width = SV_MIN_WIDTH - shellview_width_actual;
291 if(missing_width < (navpane_width_actual - NP_MIN_WIDTH))
293 /* Shrink the navpane */
294 navpane_width_actual -= missing_width;
295 shellview_width_actual += missing_width;
297 else
299 /* Hide the navpane */
300 shellview_width_actual += navpane_width_actual;
301 navpane_width_actual = 0;
305 /**************************************************************
306 * Calculate rectangles for the panes. All rectangles contain
307 * the position of the panes relative to hwnd_main.
310 if(navpane_width_actual)
312 This->navpane.rc.left = This->navpane.rc.top = 0;
313 This->navpane.rc.right = navpane_width_actual;
314 This->navpane.rc.bottom = rc.bottom;
316 if(!This->navpane.hwnd_splitter)
317 initialize_navpane(This, This->hwnd_main, &This->navpane.rc);
319 else
320 ZeroMemory(&This->navpane.rc, sizeof(RECT));
322 This->sv_rc.left = navpane_width_actual;
323 This->sv_rc.top = 0;
324 This->sv_rc.right = This->sv_rc.left + shellview_width_actual;
325 This->sv_rc.bottom = rc.bottom;
328 static void size_panes(ExplorerBrowserImpl *This)
330 MoveWindow(This->navpane.hwnd_splitter,
331 This->navpane.rc.right - SPLITTER_WIDTH, This->navpane.rc.top,
332 SPLITTER_WIDTH, This->navpane.rc.bottom - This->navpane.rc.top,
333 TRUE);
335 MoveWindow(This->hwnd_sv,
336 This->sv_rc.left, This->sv_rc.top,
337 This->sv_rc.right - This->sv_rc.left, This->sv_rc.bottom - This->sv_rc.top,
338 TRUE);
341 static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
343 IFolderView *pfv;
344 HRESULT hr;
346 if(!This->psv)
347 return E_FAIL;
349 hr = IShellView_QueryInterface(This->psv, &IID_IFolderView, (void*)&pfv);
350 if(SUCCEEDED(hr))
352 hr = IFolderView_SetCurrentViewMode(pfv, This->fs.ViewMode);
353 IFolderView_Release(pfv);
356 return hr;
359 static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi)
361 IShellBrowser *psb = &This->IShellBrowser_iface;
362 IShellFolder *psf;
363 IShellView *psv;
364 HWND hwnd_new;
365 HRESULT hr;
367 TRACE("%p, %p\n", This, psi);
369 hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFObject, &IID_IShellFolder, (void**)&psf);
370 if(SUCCEEDED(hr))
372 hr = IShellFolder_CreateViewObject(psf, This->hwnd_main, &IID_IShellView, (void**)&psv);
373 if(SUCCEEDED(hr))
375 if(This->hwnd_sv)
377 IShellView_DestroyViewWindow(This->psv);
378 This->hwnd_sv = NULL;
381 hr = IShellView_CreateViewWindow(psv, This->psv, &This->fs, psb, &This->sv_rc, &hwnd_new);
382 if(SUCCEEDED(hr))
384 /* Replace the old shellview */
385 if(This->psv) IShellView_Release(This->psv);
387 This->psv = psv;
388 This->hwnd_sv = hwnd_new;
389 events_ViewCreated(This, psv);
391 else
393 ERR("CreateViewWindow failed (0x%x)\n", hr);
394 IShellView_Release(psv);
397 else
398 ERR("CreateViewObject failed (0x%x)\n", hr);
400 IShellFolder_Release(psf);
402 else
403 ERR("SI::BindToHandler failed (0x%x)\n", hr);
405 return hr;
408 static void get_interfaces_from_site(ExplorerBrowserImpl *This)
410 IServiceProvider *psp;
411 HRESULT hr;
413 /* Calling this with This->punk_site set to NULL should properly
414 * release any previously fetched interfaces.
417 if(This->pcdb_site)
419 ICommDlgBrowser_Release(This->pcdb_site);
420 if(This->pcdb2_site) ICommDlgBrowser2_Release(This->pcdb2_site);
421 if(This->pcdb3_site) ICommDlgBrowser3_Release(This->pcdb3_site);
423 This->pcdb_site = NULL;
424 This->pcdb2_site = NULL;
425 This->pcdb3_site = NULL;
428 if(This->pepv_site)
430 IExplorerPaneVisibility_Release(This->pepv_site);
431 This->pepv_site = NULL;
434 if(!This->punk_site)
435 return;
437 hr = IUnknown_QueryInterface(This->punk_site, &IID_IServiceProvider, (void**)&psp);
438 if(FAILED(hr))
440 ERR("Failed to get IServiceProvider from site.\n");
441 return;
444 /* ICommDlgBrowser */
445 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser,
446 (void**)&This->pcdb_site);
447 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2,
448 (void**)&This->pcdb2_site);
449 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3,
450 (void**)&This->pcdb3_site);
452 /* IExplorerPaneVisibility */
453 IServiceProvider_QueryService(psp, &SID_ExplorerPaneVisibility, &IID_IExplorerPaneVisibility,
454 (void**)&This->pepv_site);
456 IServiceProvider_Release(psp);
459 /**************************************************************************
460 * General pane functionality.
462 static void update_panestate(ExplorerBrowserImpl *This)
464 EXPLORERPANESTATE eps = EPS_DONTCARE;
465 BOOL show_navpane;
466 TRACE("%p\n", This);
468 if(!This->pepv_site) return;
470 IExplorerPaneVisibility_GetPaneState(This->pepv_site, (REFEXPLORERPANE) &EP_NavPane, &eps);
471 if( !(eps & EPS_DEFAULT_OFF) )
472 show_navpane = TRUE;
473 else
474 show_navpane = FALSE;
476 if(This->navpane.show != show_navpane)
478 update_layout(This);
479 size_panes(This);
482 This->navpane.show = show_navpane;
485 static void splitter_draw(HWND hwnd, RECT *rc)
487 HDC hdc = GetDC(hwnd);
488 InvertRect(hdc, rc);
489 ReleaseDC(hwnd, hdc);
492 /**************************************************************************
493 * The Navigation Pane.
495 static LRESULT navpane_splitter_beginresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
497 TRACE("\n");
499 SetCapture(hwnd);
501 CopyRect(&This->splitter_rc, &This->navpane.rc);
502 This->splitter_rc.left = This->splitter_rc.right - SPLITTER_WIDTH;
504 splitter_draw(GetParent(hwnd), &This->splitter_rc);
506 return TRUE;
509 static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
511 int new_width, dx;
512 RECT rc;
514 if(GetCapture() != hwnd) return FALSE;
516 dx = (SHORT)LOWORD(lParam);
517 TRACE("%d.\n", dx);
519 CopyRect(&rc, &This->navpane.rc);
521 new_width = This->navpane.width + dx;
522 if(new_width > NP_MIN_WIDTH && This->sv_rc.right - new_width > SV_MIN_WIDTH)
524 rc.right = new_width;
525 rc.left = rc.right - SPLITTER_WIDTH;
526 splitter_draw(GetParent(hwnd), &This->splitter_rc);
527 splitter_draw(GetParent(hwnd), &rc);
528 CopyRect(&This->splitter_rc, &rc);
531 return TRUE;
534 static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
536 int new_width, dx;
538 if(GetCapture() != hwnd) return FALSE;
540 dx = (SHORT)LOWORD(lParam);
541 TRACE("%d.\n", dx);
543 splitter_draw(GetParent(hwnd), &This->splitter_rc);
545 new_width = This->navpane.width + dx;
546 if(new_width < NP_MIN_WIDTH)
547 new_width = NP_MIN_WIDTH;
548 else if(This->sv_rc.right - new_width < SV_MIN_WIDTH)
549 new_width = This->sv_rc.right - SV_MIN_WIDTH;
551 This->navpane.width = new_width;
553 update_layout(This);
554 size_panes(This);
556 ReleaseCapture();
558 return TRUE;
561 static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
563 ExplorerBrowserImpl *This = crs->lpCreateParams;
564 INameSpaceTreeControl2 *pnstc2;
565 DWORD style;
566 HRESULT hr;
568 TRACE("%p\n", This);
569 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LPARAM)This);
570 This->navpane.hwnd_splitter = hwnd;
572 hr = CoCreateInstance(&CLSID_NamespaceTreeControl, NULL, CLSCTX_INPROC_SERVER,
573 &IID_INameSpaceTreeControl2, (void**)&pnstc2);
575 if(SUCCEEDED(hr))
577 style = NSTCS_HASEXPANDOS | NSTCS_ROOTHASEXPANDO | NSTCS_SHOWSELECTIONALWAYS;
578 hr = INameSpaceTreeControl2_Initialize(pnstc2, GetParent(hwnd), NULL, style);
579 if(SUCCEEDED(hr))
581 INameSpaceTreeControlEvents *pnstce;
582 IShellFolder *psfdesktop;
583 IShellItem *psi;
584 IOleWindow *pow;
585 LPITEMIDLIST pidl;
586 DWORD cookie, style2 = NSTCS2_DISPLAYPADDING;
588 hr = INameSpaceTreeControl2_SetControlStyle2(pnstc2, 0xFF, style2);
589 if(FAILED(hr))
590 ERR("SetControlStyle2 failed (0x%08x)\n", hr);
592 hr = INameSpaceTreeControl2_QueryInterface(pnstc2, &IID_IOleWindow, (void**)&pow);
593 if(SUCCEEDED(hr))
595 IOleWindow_GetWindow(pow, &This->navpane.hwnd_nstc);
596 IOleWindow_Release(pow);
598 else
599 ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr);
601 pnstce = &This->INameSpaceTreeControlEvents_iface;
602 hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie);
603 if(FAILED(hr))
604 ERR("TreeAdvise failed. (0x%08x).\n", hr);
607 * Add the default roots
610 /* TODO: This should be FOLDERID_Links */
611 hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
612 if(SUCCEEDED(hr))
614 hr = SHCreateShellItem(NULL, NULL, pidl, &psi);
615 if(SUCCEEDED(hr))
617 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_NONFOLDERS, NSTCRS_VISIBLE, NULL);
618 IShellItem_Release(psi);
620 ILFree(pidl);
623 SHGetDesktopFolder(&psfdesktop);
624 hr = SHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
625 IShellFolder_Release(psfdesktop);
626 if(SUCCEEDED(hr))
628 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_FOLDERS, NSTCRS_EXPANDED, NULL);
629 IShellItem_Release(psi);
632 /* TODO:
633 * We should advertise IID_INameSpaceTreeControl to the site of the
634 * host through its IProfferService interface, if any.
637 This->navpane.pnstc2 = pnstc2;
638 This->navpane.nstc_cookie = cookie;
640 return TRUE;
644 This->navpane.pnstc2 = NULL;
645 ERR("Failed (0x%08x)\n", hr);
647 return FALSE;
650 static LRESULT navpane_on_wm_size_move(ExplorerBrowserImpl *This)
652 UINT height, width;
653 TRACE("%p\n", This);
655 width = This->navpane.rc.right - This->navpane.rc.left - SPLITTER_WIDTH;
656 height = This->navpane.rc.bottom - This->navpane.rc.top;
658 MoveWindow(This->navpane.hwnd_nstc,
659 This->navpane.rc.left, This->navpane.rc.top,
660 width, height,
661 TRUE);
663 return FALSE;
666 static LRESULT navpane_on_wm_destroy(ExplorerBrowserImpl *This)
668 INameSpaceTreeControl2_TreeUnadvise(This->navpane.pnstc2, This->navpane.nstc_cookie);
669 INameSpaceTreeControl2_Release(This->navpane.pnstc2);
670 This->navpane.pnstc2 = NULL;
671 return TRUE;
674 static LRESULT CALLBACK navpane_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
676 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
678 switch(uMessage) {
679 case WM_CREATE: return navpane_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
680 case WM_MOVE: /* Fall through */
681 case WM_SIZE: return navpane_on_wm_size_move(This);
682 case WM_DESTROY: return navpane_on_wm_destroy(This);
683 case WM_LBUTTONDOWN: return navpane_splitter_beginresize(This, hWnd, lParam);
684 case WM_MOUSEMOVE: return navpane_splitter_resizing(This, hWnd, lParam);
685 case WM_LBUTTONUP: return navpane_splitter_endresize(This, hWnd, lParam);
686 default:
687 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
689 return 0;
692 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc)
694 WNDCLASSW wc;
695 HWND splitter;
696 static const WCHAR navpane_classname[] = {'e','b','_','n','a','v','p','a','n','e',0};
698 if( !GetClassInfoW(shell32_hInstance, navpane_classname, &wc) )
700 wc.style = CS_HREDRAW | CS_VREDRAW;
701 wc.lpfnWndProc = navpane_wndproc;
702 wc.cbClsExtra = 0;
703 wc.cbWndExtra = 0;
704 wc.hInstance = shell32_hInstance;
705 wc.hIcon = 0;
706 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_SIZEWE);
707 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
708 wc.lpszMenuName = NULL;
709 wc.lpszClassName = navpane_classname;
711 if (!RegisterClassW(&wc)) return;
714 splitter = CreateWindowExW(0, navpane_classname, NULL,
715 WS_CHILD | WS_TABSTOP | WS_VISIBLE,
716 rc->right - SPLITTER_WIDTH, rc->top,
717 SPLITTER_WIDTH, rc->bottom - rc->top,
718 hwnd_parent, 0, shell32_hInstance, This);
719 if(!splitter)
720 ERR("Failed to create navpane : %d.\n", GetLastError());
723 /**************************************************************************
724 * Main window related functions.
726 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
728 ExplorerBrowserImpl *This = crs->lpCreateParams;
729 TRACE("%p\n", This);
731 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
732 This->hwnd_main = hWnd;
734 return TRUE;
737 static LRESULT main_on_wm_size(ExplorerBrowserImpl *This)
739 update_layout(This);
740 size_panes(This);
742 return TRUE;
745 static LRESULT main_on_cwm_getishellbrowser(ExplorerBrowserImpl *This)
747 return (LRESULT)&This->IShellBrowser_iface;
750 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
752 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
754 switch(uMessage)
756 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
757 case WM_SIZE: return main_on_wm_size(This);
758 case CWM_GETISHELLBROWSER: return main_on_cwm_getishellbrowser(This);
759 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
762 return 0;
765 /**************************************************************************
766 * IExplorerBrowser Implementation
769 static inline ExplorerBrowserImpl *impl_from_IExplorerBrowser(IExplorerBrowser *iface)
771 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IExplorerBrowser_iface);
774 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
775 REFIID riid, void **ppvObject)
777 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
778 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
780 *ppvObject = NULL;
781 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
782 IsEqualIID(riid, &IID_IUnknown))
784 *ppvObject = &This->IExplorerBrowser_iface;
786 else if(IsEqualIID(riid, &IID_IShellBrowser))
788 *ppvObject = &This->IShellBrowser_iface;
790 else if(IsEqualIID(riid, &IID_ICommDlgBrowser) ||
791 IsEqualIID(riid, &IID_ICommDlgBrowser2) ||
792 IsEqualIID(riid, &IID_ICommDlgBrowser3))
794 *ppvObject = &This->ICommDlgBrowser3_iface;
796 else if(IsEqualIID(riid, &IID_IObjectWithSite))
798 *ppvObject = &This->IObjectWithSite_iface;
800 else if(IsEqualIID(riid, &IID_IInputObject))
802 *ppvObject = &This->IInputObject_iface;
805 if(*ppvObject)
807 IUnknown_AddRef((IUnknown*)*ppvObject);
808 return S_OK;
811 return E_NOINTERFACE;
814 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
816 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
817 LONG ref = InterlockedIncrement(&This->ref);
818 TRACE("%p - ref %d\n", This, ref);
820 return ref;
823 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
825 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
826 LONG ref = InterlockedDecrement(&This->ref);
827 TRACE("%p - ref %d\n", This, ref);
829 if(!ref)
831 TRACE("Freeing.\n");
833 if(!This->destroyed)
834 IExplorerBrowser_Destroy(iface);
836 IObjectWithSite_SetSite(&This->IObjectWithSite_iface, NULL);
838 HeapFree(GetProcessHeap(), 0, This);
839 return 0;
842 return ref;
845 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
846 HWND hwndParent, const RECT *prc,
847 const FOLDERSETTINGS *pfs)
849 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
850 WNDCLASSW wc;
851 LONG style;
852 static const WCHAR EB_CLASS_NAME[] =
853 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
855 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
857 if(This->hwnd_main)
858 return E_UNEXPECTED;
860 if(!hwndParent)
861 return E_INVALIDARG;
863 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
865 wc.style = CS_HREDRAW | CS_VREDRAW;
866 wc.lpfnWndProc = main_wndproc;
867 wc.cbClsExtra = 0;
868 wc.cbWndExtra = 0;
869 wc.hInstance = shell32_hInstance;
870 wc.hIcon = 0;
871 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
872 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
873 wc.lpszMenuName = NULL;
874 wc.lpszClassName = EB_CLASS_NAME;
876 if (!RegisterClassW(&wc)) return E_FAIL;
879 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
880 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
881 prc->left, prc->top,
882 prc->right - prc->left, prc->bottom - prc->top,
883 hwndParent, 0, shell32_hInstance, This);
885 if(!This->hwnd_main)
887 ERR("Failed to create the window.\n");
888 return E_FAIL;
891 This->fs.ViewMode = pfs ? pfs->ViewMode : FVM_DETAILS;
892 This->fs.fFlags = pfs ? (pfs->fFlags | FWF_NOCLIENTEDGE) : FWF_NOCLIENTEDGE;
894 return S_OK;
897 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
899 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
900 TRACE("%p\n", This);
902 if(This->psv)
904 IShellView_DestroyViewWindow(This->psv);
905 IShellView_Release(This->psv);
906 This->psv = NULL;
907 This->hwnd_sv = NULL;
910 events_unadvise_all(This);
911 travellog_remove_all_entries(This);
913 ILFree(This->current_pidl);
914 This->current_pidl = NULL;
916 DestroyWindow(This->hwnd_main);
917 This->destroyed = TRUE;
919 return S_OK;
922 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
923 HDWP *phdwp, RECT rcBrowser)
925 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
926 TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
928 if(phdwp && *phdwp)
930 *phdwp = DeferWindowPos(*phdwp, This->hwnd_main, NULL, rcBrowser.left, rcBrowser.top,
931 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top,
932 SWP_NOZORDER | SWP_NOACTIVATE);
933 if(!*phdwp)
934 return E_FAIL;
936 else
938 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
939 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
942 return S_OK;
945 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
946 LPCWSTR pszPropertyBag)
948 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
949 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
951 if(!pszPropertyBag)
952 return E_INVALIDARG;
954 /* FIXME: This method is currently useless as we don't save any
955 * settings anywhere, but at least one application breaks if we
956 * return E_NOTIMPL.
959 return S_OK;
962 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
963 LPCWSTR pszEmptyText)
965 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
966 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
968 return E_NOTIMPL;
971 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
972 const FOLDERSETTINGS *pfs)
974 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
975 TRACE("%p (%p)\n", This, pfs);
977 if(!pfs)
978 return E_INVALIDARG;
980 This->fs.ViewMode = pfs->ViewMode;
981 This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
983 /* Change the settings of the current view, if any. */
984 return change_viewmode(This, This->fs.ViewMode);
987 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
988 IExplorerBrowserEvents *psbe,
989 DWORD *pdwCookie)
991 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
992 event_client *client;
993 TRACE("%p (%p, %p)\n", This, psbe, pdwCookie);
995 client = HeapAlloc(GetProcessHeap(), 0, sizeof(event_client));
996 client->pebe = psbe;
997 client->cookie = ++This->events_next_cookie;
999 IExplorerBrowserEvents_AddRef(psbe);
1000 *pdwCookie = client->cookie;
1002 list_add_tail(&This->event_clients, &client->entry);
1004 return S_OK;
1007 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
1008 DWORD dwCookie)
1010 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1011 event_client *client;
1012 TRACE("%p (0x%x)\n", This, dwCookie);
1014 LIST_FOR_EACH_ENTRY(client, &This->event_clients, event_client, entry)
1016 if(client->cookie == dwCookie)
1018 list_remove(&client->entry);
1019 IExplorerBrowserEvents_Release(client->pebe);
1020 HeapFree(GetProcessHeap(), 0, client);
1021 return S_OK;
1025 return E_INVALIDARG;
1028 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
1029 EXPLORER_BROWSER_OPTIONS dwFlag)
1031 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1032 static const EXPLORER_BROWSER_OPTIONS unsupported_options =
1033 EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW;
1035 TRACE("%p (0x%x)\n", This, dwFlag);
1037 if(dwFlag & unsupported_options)
1038 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag);
1040 This->eb_options = dwFlag;
1042 return S_OK;
1045 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
1046 EXPLORER_BROWSER_OPTIONS *pdwFlag)
1048 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1049 TRACE("%p (%p)\n", This, pdwFlag);
1051 *pdwFlag = This->eb_options;
1053 return S_OK;
1056 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
1057 PCUIDLIST_RELATIVE pidl,
1058 UINT uFlags)
1060 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1061 LPITEMIDLIST absolute_pidl = NULL;
1062 HRESULT hr;
1063 static const UINT unsupported_browse_flags =
1064 SBSP_NEWBROWSER | EBF_SELECTFROMDATAOBJECT | EBF_NODROPTARGET;
1065 TRACE("%p (%p, 0x%x)\n", This, pidl, uFlags);
1067 if(!This->hwnd_main)
1068 return E_FAIL;
1070 if(This->destroyed)
1071 return HRESULT_FROM_WIN32(ERROR_BUSY);
1073 if(This->current_pidl && (This->eb_options & EBO_NAVIGATEONCE))
1074 return E_FAIL;
1076 if(uFlags & SBSP_EXPLOREMODE)
1077 return E_INVALIDARG;
1079 if(uFlags & unsupported_browse_flags)
1080 FIXME("Argument 0x%x contains unsupported flags.\n", uFlags);
1082 if(uFlags & SBSP_NAVIGATEBACK)
1084 TRACE("SBSP_NAVIGATEBACK\n");
1085 absolute_pidl = ILClone(travellog_go_back(This));
1086 if(!absolute_pidl && !This->current_pidl)
1087 return E_FAIL;
1088 else if(!absolute_pidl)
1089 return S_OK;
1092 else if(uFlags & SBSP_NAVIGATEFORWARD)
1094 TRACE("SBSP_NAVIGATEFORWARD\n");
1095 absolute_pidl = ILClone(travellog_go_forward(This));
1096 if(!absolute_pidl && !This->current_pidl)
1097 return E_FAIL;
1098 else if(!absolute_pidl)
1099 return S_OK;
1102 else if(uFlags & SBSP_PARENT)
1104 if(This->current_pidl)
1106 if(_ILIsPidlSimple(This->current_pidl))
1108 absolute_pidl = _ILCreateDesktop();
1110 else
1112 absolute_pidl = ILClone(This->current_pidl);
1113 ILRemoveLastID(absolute_pidl);
1116 if(!absolute_pidl)
1118 ERR("Failed to get parent pidl.\n");
1119 return E_FAIL;
1123 else if(uFlags & SBSP_RELATIVE)
1125 /* SBSP_RELATIVE has precedence over SBSP_ABSOLUTE */
1126 TRACE("SBSP_RELATIVE\n");
1127 if(This->current_pidl)
1129 absolute_pidl = ILCombine(This->current_pidl, pidl);
1131 if(!absolute_pidl)
1133 ERR("Failed to get absolute pidl.\n");
1134 return E_FAIL;
1137 else
1139 TRACE("SBSP_ABSOLUTE\n");
1140 absolute_pidl = ILClone(pidl);
1141 if(!absolute_pidl && !This->current_pidl)
1142 return E_INVALIDARG;
1143 else if(!absolute_pidl)
1144 return S_OK;
1147 /* TODO: Asynchronous browsing. Return S_OK here and finish in
1148 * another thread. */
1150 hr = events_NavigationPending(This, absolute_pidl);
1151 if(FAILED(hr))
1153 TRACE("Browsing aborted.\n");
1154 ILFree(absolute_pidl);
1155 return E_FAIL;
1158 get_interfaces_from_site(This);
1159 update_panestate(This);
1161 /* Only browse if the new pidl differs from the old */
1162 if(!ILIsEqual(This->current_pidl, absolute_pidl))
1164 IShellItem *psi;
1165 hr = SHCreateItemFromIDList(absolute_pidl, &IID_IShellItem, (void**)&psi);
1166 if(SUCCEEDED(hr))
1168 hr = create_new_shellview(This, psi);
1169 if(FAILED(hr))
1171 events_NavigationFailed(This, absolute_pidl);
1172 ILFree(absolute_pidl);
1173 IShellItem_Release(psi);
1174 return E_FAIL;
1177 /* Add to travellog */
1178 if( !(This->eb_options & EBO_NOTRAVELLOG) &&
1179 !(uFlags & (SBSP_NAVIGATEFORWARD|SBSP_NAVIGATEBACK)) )
1181 travellog_add_entry(This, absolute_pidl);
1184 IShellItem_Release(psi);
1188 events_NavigationComplete(This, absolute_pidl);
1189 ILFree(This->current_pidl);
1190 This->current_pidl = absolute_pidl;
1192 /* Expand the NameSpaceTree to the current location. */
1193 if(This->navpane.show && This->navpane.pnstc2)
1195 IShellItem *psi;
1196 hr = SHCreateItemFromIDList(This->current_pidl, &IID_IShellItem, (void**)&psi);
1197 if(SUCCEEDED(hr))
1199 INameSpaceTreeControl2_EnsureItemVisible(This->navpane.pnstc2, psi);
1200 IShellItem_Release(psi);
1204 return S_OK;
1207 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
1208 IUnknown *punk, UINT uFlags)
1210 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1211 LPITEMIDLIST pidl;
1212 HRESULT hr;
1213 TRACE("%p (%p, 0x%x)\n", This, punk, uFlags);
1215 if(!punk)
1216 return IExplorerBrowser_BrowseToIDList(iface, NULL, uFlags);
1218 hr = SHGetIDListFromObject(punk, &pidl);
1219 if(SUCCEEDED(hr))
1221 hr = IExplorerBrowser_BrowseToIDList(iface, pidl, uFlags);
1222 ILFree(pidl);
1225 return hr;
1228 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
1229 IUnknown *punk,
1230 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
1232 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1233 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
1240 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1241 FIXME("stub, %p\n", This);
1243 return E_NOTIMPL;
1246 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
1247 REFIID riid, void **ppv)
1249 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1250 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
1252 if(!This->psv)
1253 return E_FAIL;
1255 return IShellView_QueryInterface(This->psv, riid, ppv);
1258 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
1260 IExplorerBrowser_fnQueryInterface,
1261 IExplorerBrowser_fnAddRef,
1262 IExplorerBrowser_fnRelease,
1263 IExplorerBrowser_fnInitialize,
1264 IExplorerBrowser_fnDestroy,
1265 IExplorerBrowser_fnSetRect,
1266 IExplorerBrowser_fnSetPropertyBag,
1267 IExplorerBrowser_fnSetEmptyText,
1268 IExplorerBrowser_fnSetFolderSettings,
1269 IExplorerBrowser_fnAdvise,
1270 IExplorerBrowser_fnUnadvise,
1271 IExplorerBrowser_fnSetOptions,
1272 IExplorerBrowser_fnGetOptions,
1273 IExplorerBrowser_fnBrowseToIDList,
1274 IExplorerBrowser_fnBrowseToObject,
1275 IExplorerBrowser_fnFillFromObject,
1276 IExplorerBrowser_fnRemoveAll,
1277 IExplorerBrowser_fnGetCurrentView
1280 /**************************************************************************
1281 * IShellBrowser Implementation
1284 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
1286 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IShellBrowser_iface);
1289 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
1290 REFIID riid, void **ppvObject)
1292 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1293 TRACE("%p\n", This);
1294 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1297 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
1299 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1300 TRACE("%p\n", This);
1301 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1304 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
1306 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1307 TRACE("%p\n", This);
1308 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1311 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
1313 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1314 TRACE("%p (%p)\n", This, phwnd);
1316 if(!This->hwnd_main)
1317 return E_FAIL;
1319 *phwnd = This->hwnd_main;
1320 return S_OK;
1323 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
1324 BOOL fEnterMode)
1326 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1327 FIXME("stub, %p (%d)\n", This, fEnterMode);
1329 return E_NOTIMPL;
1332 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
1333 HMENU hmenuShared,
1334 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1336 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1337 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
1339 /* Not implemented. */
1340 return E_NOTIMPL;
1343 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
1344 HMENU hmenuShared,
1345 HOLEMENU holemenuReserved,
1346 HWND hwndActiveObject)
1348 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1349 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
1351 /* Not implemented. */
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
1356 HMENU hmenuShared)
1358 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1359 TRACE("%p (%p)\n", This, hmenuShared);
1361 /* Not implemented. */
1362 return E_NOTIMPL;
1365 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
1366 LPCOLESTR pszStatusText)
1368 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1369 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
1371 return E_NOTIMPL;
1374 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
1375 BOOL fEnable)
1377 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1378 FIXME("stub, %p (%d)\n", This, fEnable);
1380 return E_NOTIMPL;
1383 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
1384 MSG *pmsg, WORD wID)
1386 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1387 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
1389 return E_NOTIMPL;
1392 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
1393 LPCITEMIDLIST pidl, UINT wFlags)
1395 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1396 TRACE("%p (%p, %x)\n", This, pidl, wFlags);
1398 return IExplorerBrowser_BrowseToIDList(&This->IExplorerBrowser_iface, pidl, wFlags);
1401 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
1402 DWORD grfMode,
1403 IStream **ppStrm)
1405 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1406 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
1408 *ppStrm = NULL;
1409 return E_FAIL;
1412 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
1413 UINT id, HWND *phwnd)
1415 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1416 TRACE("(%p)->(%d, %p)\n", This, id, phwnd);
1417 if (phwnd) *phwnd = NULL;
1418 return E_NOTIMPL;
1421 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
1422 UINT id, UINT uMsg,
1423 WPARAM wParam, LPARAM lParam,
1424 LRESULT *pret)
1426 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1427 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
1429 return E_NOTIMPL;
1432 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
1433 IShellView **ppshv)
1435 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1436 TRACE("%p (%p)\n", This, ppshv);
1438 if(!This->psv)
1439 return E_FAIL;
1441 *ppshv = This->psv;
1442 IShellView_AddRef(This->psv);
1444 return S_OK;
1447 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
1448 IShellView *pshv)
1450 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1451 FIXME("stub, %p (%p)\n", This, pshv);
1453 return E_NOTIMPL;
1456 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
1457 LPTBBUTTONSB lpButtons,
1458 UINT nButtons, UINT uFlags)
1460 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1461 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
1463 return E_NOTIMPL;
1466 static const IShellBrowserVtbl vt_IShellBrowser = {
1467 IShellBrowser_fnQueryInterface,
1468 IShellBrowser_fnAddRef,
1469 IShellBrowser_fnRelease,
1470 IShellBrowser_fnGetWindow,
1471 IShellBrowser_fnContextSensitiveHelp,
1472 IShellBrowser_fnInsertMenusSB,
1473 IShellBrowser_fnSetMenuSB,
1474 IShellBrowser_fnRemoveMenusSB,
1475 IShellBrowser_fnSetStatusTextSB,
1476 IShellBrowser_fnEnableModelessSB,
1477 IShellBrowser_fnTranslateAcceleratorSB,
1478 IShellBrowser_fnBrowseObject,
1479 IShellBrowser_fnGetViewStateStream,
1480 IShellBrowser_fnGetControlWindow,
1481 IShellBrowser_fnSendControlMsg,
1482 IShellBrowser_fnQueryActiveShellView,
1483 IShellBrowser_fnOnViewWindowActive,
1484 IShellBrowser_fnSetToolbarItems
1487 /**************************************************************************
1488 * ICommDlgBrowser3 Implementation
1491 static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
1493 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, ICommDlgBrowser3_iface);
1496 static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface,
1497 REFIID riid,
1498 void **ppvObject)
1500 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1501 TRACE("%p\n", This);
1502 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1505 static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
1507 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1508 TRACE("%p\n", This);
1509 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1512 static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
1514 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1515 TRACE("%p\n", This);
1516 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1519 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *iface,
1520 IShellView *shv)
1522 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1523 IDataObject *pdo;
1524 HRESULT hr;
1525 HRESULT ret = S_FALSE;
1527 TRACE("%p (%p)\n", This, shv);
1529 hr = IShellView_GetItemObject(shv, SVGIO_SELECTION, &IID_IDataObject, (void**)&pdo);
1530 if(SUCCEEDED(hr))
1532 FORMATETC fmt;
1533 STGMEDIUM medium;
1535 fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
1536 fmt.ptd = NULL;
1537 fmt.dwAspect = DVASPECT_CONTENT;
1538 fmt.lindex = -1;
1539 fmt.tymed = TYMED_HGLOBAL;
1541 hr = IDataObject_GetData(pdo, &fmt ,&medium);
1542 IDataObject_Release(pdo);
1543 if(SUCCEEDED(hr))
1545 LPIDA pida = GlobalLock(medium.u.hGlobal);
1546 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
1548 /* Handle folders by browsing to them. */
1549 if(_ILIsFolder(pidl_child) || _ILIsDrive(pidl_child) || _ILIsSpecialFolder(pidl_child))
1551 IExplorerBrowser_BrowseToIDList(&This->IExplorerBrowser_iface, pidl_child, SBSP_RELATIVE);
1552 ret = S_OK;
1554 GlobalUnlock(medium.u.hGlobal);
1555 GlobalFree(medium.u.hGlobal);
1557 else
1558 ERR("Failed to get data from IDataObject.\n");
1559 } else
1560 ERR("Failed to get IDataObject.\n");
1562 /* If we didn't handle the default command, check if we have a
1563 * client that does */
1564 if(ret == S_FALSE && This->pcdb_site)
1565 return ICommDlgBrowser_OnDefaultCommand(This->pcdb_site, shv);
1567 return ret;
1569 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface,
1570 IShellView *shv, ULONG uChange)
1572 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1573 TRACE("%p (%p, %d)\n", This, shv, uChange);
1575 if(This->pcdb_site)
1576 return ICommDlgBrowser_OnStateChange(This->pcdb_site, shv, uChange);
1578 return E_NOTIMPL;
1580 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
1581 IShellView *pshv, LPCITEMIDLIST pidl)
1583 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1584 TRACE("%p (%p, %p)\n", This, pshv, pidl);
1586 if(This->pcdb_site)
1587 return ICommDlgBrowser_IncludeObject(This->pcdb_site, pshv, pidl);
1589 return S_OK;
1592 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
1593 IShellView *pshv,
1594 DWORD dwNotifyType)
1596 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1597 TRACE("%p (%p, 0x%x)\n", This, pshv, dwNotifyType);
1599 if(This->pcdb2_site)
1600 return ICommDlgBrowser2_Notify(This->pcdb2_site, pshv, dwNotifyType);
1602 return S_OK;
1605 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(ICommDlgBrowser3 *iface,
1606 IShellView *pshv,
1607 LPWSTR pszText, int cchMax)
1609 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1610 TRACE("%p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
1612 if(This->pcdb2_site)
1613 return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb2_site, pshv, pszText, cchMax);
1615 return S_OK;
1618 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(ICommDlgBrowser3 *iface,
1619 DWORD *pdwFlags)
1621 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1622 TRACE("%p (%p)\n", This, pdwFlags);
1624 if(This->pcdb2_site)
1625 return ICommDlgBrowser2_GetViewFlags(This->pcdb2_site, pdwFlags);
1627 return S_OK;
1630 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(ICommDlgBrowser3 *iface,
1631 IShellView *pshv, int iColumn)
1633 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1634 TRACE("%p (%p, %d)\n", This, pshv, iColumn);
1636 if(This->pcdb3_site)
1637 return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
1639 return S_OK;
1642 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(ICommDlgBrowser3 *iface,
1643 LPWSTR pszFileSpec,
1644 int cchFileSpec)
1646 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1647 TRACE("%p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
1649 if(This->pcdb3_site)
1650 return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
1652 return S_OK;
1655 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(ICommDlgBrowser3 *iface,
1656 IShellView *pshv)
1658 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1659 TRACE("%p (%p)\n", This, pshv);
1661 if(This->pcdb3_site)
1662 return ICommDlgBrowser3_OnPreviewCreated(This->pcdb3_site, pshv);
1664 return S_OK;
1667 static const ICommDlgBrowser3Vtbl vt_ICommDlgBrowser3 = {
1668 ICommDlgBrowser3_fnQueryInterface,
1669 ICommDlgBrowser3_fnAddRef,
1670 ICommDlgBrowser3_fnRelease,
1671 ICommDlgBrowser3_fnOnDefaultCommand,
1672 ICommDlgBrowser3_fnOnStateChange,
1673 ICommDlgBrowser3_fnIncludeObject,
1674 ICommDlgBrowser3_fnNotify,
1675 ICommDlgBrowser3_fnGetDefaultMenuText,
1676 ICommDlgBrowser3_fnGetViewFlags,
1677 ICommDlgBrowser3_fnOnColumnClicked,
1678 ICommDlgBrowser3_fnGetCurrentFilter,
1679 ICommDlgBrowser3_fnOnPreviewCreated
1682 /**************************************************************************
1683 * IObjectWithSite Implementation
1686 static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
1688 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IObjectWithSite_iface);
1691 static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface,
1692 REFIID riid, void **ppvObject)
1694 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1695 TRACE("%p\n", This);
1696 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1699 static ULONG WINAPI IObjectWithSite_fnAddRef(IObjectWithSite *iface)
1701 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1702 TRACE("%p\n", This);
1703 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1706 static ULONG WINAPI IObjectWithSite_fnRelease(IObjectWithSite *iface)
1708 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1709 TRACE("%p\n", This);
1710 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1713 static HRESULT WINAPI IObjectWithSite_fnSetSite(IObjectWithSite *iface, IUnknown *punk_site)
1715 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1716 TRACE("%p (%p)\n", This, punk_site);
1718 if(This->punk_site)
1720 IUnknown_Release(This->punk_site);
1721 This->punk_site = NULL;
1722 get_interfaces_from_site(This);
1725 This->punk_site = punk_site;
1727 if(This->punk_site)
1728 IUnknown_AddRef(This->punk_site);
1730 return S_OK;
1733 static HRESULT WINAPI IObjectWithSite_fnGetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite)
1735 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1736 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvSite);
1738 if(!This->punk_site)
1739 return E_FAIL;
1741 return IUnknown_QueryInterface(This->punk_site, riid, ppvSite);
1744 static const IObjectWithSiteVtbl vt_IObjectWithSite = {
1745 IObjectWithSite_fnQueryInterface,
1746 IObjectWithSite_fnAddRef,
1747 IObjectWithSite_fnRelease,
1748 IObjectWithSite_fnSetSite,
1749 IObjectWithSite_fnGetSite
1752 /**************************************************************************
1753 * INameSpaceTreeControlEvents Implementation
1755 static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
1757 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, INameSpaceTreeControlEvents_iface);
1760 static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface,
1761 REFIID riid, void **ppvObject)
1763 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1764 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
1766 *ppvObject = NULL;
1767 if(IsEqualIID(riid, &IID_INameSpaceTreeControlEvents) ||
1768 IsEqualIID(riid, &IID_IUnknown))
1770 *ppvObject = iface;
1773 if(*ppvObject)
1775 IUnknown_AddRef((IUnknown*)*ppvObject);
1776 return S_OK;
1779 return E_NOINTERFACE;
1782 static ULONG WINAPI NSTCEvents_fnAddRef(INameSpaceTreeControlEvents *iface)
1784 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1785 TRACE("%p\n", This);
1786 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1789 static ULONG WINAPI NSTCEvents_fnRelease(INameSpaceTreeControlEvents *iface)
1791 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1792 TRACE("%p\n", This);
1793 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1796 static HRESULT WINAPI NSTCEvents_fnOnItemClick(INameSpaceTreeControlEvents *iface,
1797 IShellItem *psi,
1798 NSTCEHITTEST nstceHitTest,
1799 NSTCECLICKTYPE nstceClickType)
1801 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1802 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstceHitTest, nstceClickType);
1803 return S_OK;
1806 static HRESULT WINAPI NSTCEvents_fnOnPropertyItemCommit(INameSpaceTreeControlEvents *iface,
1807 IShellItem *psi)
1809 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1810 TRACE("%p (%p)\n", This, psi);
1811 return E_NOTIMPL;
1814 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanging(INameSpaceTreeControlEvents *iface,
1815 IShellItem *psi,
1816 NSTCITEMSTATE nstcisMask,
1817 NSTCITEMSTATE nstcisState)
1819 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1820 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1821 return E_NOTIMPL;
1824 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanged(INameSpaceTreeControlEvents *iface,
1825 IShellItem *psi,
1826 NSTCITEMSTATE nstcisMask,
1827 NSTCITEMSTATE nstcisState)
1829 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1830 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1831 return E_NOTIMPL;
1834 static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(INameSpaceTreeControlEvents *iface,
1835 IShellItemArray *psiaSelection)
1837 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1838 IShellItem *psi;
1839 HRESULT hr;
1840 TRACE("%p (%p)\n", This, psiaSelection);
1842 hr = IShellItemArray_GetItemAt(psiaSelection, 0, &psi);
1843 if(SUCCEEDED(hr))
1845 hr = IExplorerBrowser_BrowseToObject(&This->IExplorerBrowser_iface,
1846 (IUnknown*)psi, SBSP_DEFBROWSER);
1847 IShellItem_Release(psi);
1850 return hr;
1853 static HRESULT WINAPI NSTCEvents_fnOnKeyboardInput(INameSpaceTreeControlEvents *iface,
1854 UINT uMsg, WPARAM wParam, LPARAM lParam)
1856 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1857 TRACE("%p (%d, 0x%lx, 0x%lx)\n", This, uMsg, wParam, lParam);
1858 return S_OK;
1861 static HRESULT WINAPI NSTCEvents_fnOnBeforeExpand(INameSpaceTreeControlEvents *iface,
1862 IShellItem *psi)
1864 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1865 TRACE("%p (%p)\n", This, psi);
1866 return E_NOTIMPL;
1869 static HRESULT WINAPI NSTCEvents_fnOnAfterExpand(INameSpaceTreeControlEvents *iface,
1870 IShellItem *psi)
1872 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1873 TRACE("%p (%p)\n", This, psi);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI NSTCEvents_fnOnBeginLabelEdit(INameSpaceTreeControlEvents *iface,
1878 IShellItem *psi)
1880 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1881 TRACE("%p (%p)\n", This, psi);
1882 return E_NOTIMPL;
1885 static HRESULT WINAPI NSTCEvents_fnOnEndLabelEdit(INameSpaceTreeControlEvents *iface,
1886 IShellItem *psi)
1888 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1889 TRACE("%p (%p)\n", This, psi);
1890 return E_NOTIMPL;
1893 static HRESULT WINAPI NSTCEvents_fnOnGetToolTip(INameSpaceTreeControlEvents *iface,
1894 IShellItem *psi, LPWSTR pszTip, int cchTip)
1896 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1897 TRACE("%p (%p, %p, %d)\n", This, psi, pszTip, cchTip);
1898 return E_NOTIMPL;
1901 static HRESULT WINAPI NSTCEvents_fnOnBeforeItemDelete(INameSpaceTreeControlEvents *iface,
1902 IShellItem *psi)
1904 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1905 TRACE("%p (%p)\n", This, psi);
1906 return E_NOTIMPL;
1909 static HRESULT WINAPI NSTCEvents_fnOnItemAdded(INameSpaceTreeControlEvents *iface,
1910 IShellItem *psi, BOOL fIsRoot)
1912 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1913 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI NSTCEvents_fnOnItemDeleted(INameSpaceTreeControlEvents *iface,
1918 IShellItem *psi, BOOL fIsRoot)
1920 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1921 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1922 return E_NOTIMPL;
1925 static HRESULT WINAPI NSTCEvents_fnOnBeforeContextMenu(INameSpaceTreeControlEvents *iface,
1926 IShellItem *psi, REFIID riid, void **ppv)
1928 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1929 TRACE("%p (%p, %s, %p)\n", This, psi, shdebugstr_guid(riid), ppv);
1930 return E_NOTIMPL;
1933 static HRESULT WINAPI NSTCEvents_fnOnAfterContextMenu(INameSpaceTreeControlEvents *iface,
1934 IShellItem *psi, IContextMenu *pcmIn,
1935 REFIID riid, void **ppv)
1937 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1938 TRACE("%p (%p, %p, %s, %p)\n", This, psi, pcmIn, shdebugstr_guid(riid), ppv);
1939 return E_NOTIMPL;
1942 static HRESULT WINAPI NSTCEvents_fnOnBeforeStateImageChange(INameSpaceTreeControlEvents *iface,
1943 IShellItem *psi)
1945 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1946 TRACE("%p (%p)\n", This, psi);
1947 return E_NOTIMPL;
1950 static HRESULT WINAPI NSTCEvents_fnOnGetDefaultIconIndex(INameSpaceTreeControlEvents* iface,
1951 IShellItem *psi,
1952 int *piDefaultIcon, int *piOpenIcon)
1954 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1955 TRACE("%p (%p, %p, %p)\n", This, psi, piDefaultIcon, piOpenIcon);
1956 return E_NOTIMPL;
1960 static const INameSpaceTreeControlEventsVtbl vt_INameSpaceTreeControlEvents = {
1961 NSTCEvents_fnQueryInterface,
1962 NSTCEvents_fnAddRef,
1963 NSTCEvents_fnRelease,
1964 NSTCEvents_fnOnItemClick,
1965 NSTCEvents_fnOnPropertyItemCommit,
1966 NSTCEvents_fnOnItemStateChanging,
1967 NSTCEvents_fnOnItemStateChanged,
1968 NSTCEvents_fnOnSelectionChanged,
1969 NSTCEvents_fnOnKeyboardInput,
1970 NSTCEvents_fnOnBeforeExpand,
1971 NSTCEvents_fnOnAfterExpand,
1972 NSTCEvents_fnOnBeginLabelEdit,
1973 NSTCEvents_fnOnEndLabelEdit,
1974 NSTCEvents_fnOnGetToolTip,
1975 NSTCEvents_fnOnBeforeItemDelete,
1976 NSTCEvents_fnOnItemAdded,
1977 NSTCEvents_fnOnItemDeleted,
1978 NSTCEvents_fnOnBeforeContextMenu,
1979 NSTCEvents_fnOnAfterContextMenu,
1980 NSTCEvents_fnOnBeforeStateImageChange,
1981 NSTCEvents_fnOnGetDefaultIconIndex
1984 /**************************************************************************
1985 * IInputObject Implementation
1988 static inline ExplorerBrowserImpl *impl_from_IInputObject(IInputObject *iface)
1990 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IInputObject_iface);
1993 static HRESULT WINAPI IInputObject_fnQueryInterface(IInputObject *iface,
1994 REFIID riid, void **ppvObject)
1996 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
1997 TRACE("%p\n", This);
1998 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
2001 static ULONG WINAPI IInputObject_fnAddRef(IInputObject *iface)
2003 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2004 TRACE("%p\n", This);
2005 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
2008 static ULONG WINAPI IInputObject_fnRelease(IInputObject *iface)
2010 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2011 TRACE("%p\n", This);
2012 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
2015 static HRESULT WINAPI IInputObject_fnUIActivateIO(IInputObject *iface, BOOL fActivate, MSG *pMsg)
2017 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2018 FIXME("stub, %p (%d, %p)\n", This, fActivate, pMsg);
2019 return E_NOTIMPL;
2022 static HRESULT WINAPI IInputObject_fnHasFocusIO(IInputObject *iface)
2024 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2025 FIXME("stub, %p\n", This);
2026 return E_NOTIMPL;
2029 static HRESULT WINAPI IInputObject_fnTranslateAcceleratorIO(IInputObject *iface, MSG *pMsg)
2031 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2032 FIXME("stub, %p (%p)\n", This, pMsg);
2033 return E_NOTIMPL;
2036 static IInputObjectVtbl vt_IInputObject = {
2037 IInputObject_fnQueryInterface,
2038 IInputObject_fnAddRef,
2039 IInputObject_fnRelease,
2040 IInputObject_fnUIActivateIO,
2041 IInputObject_fnHasFocusIO,
2042 IInputObject_fnTranslateAcceleratorIO
2045 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
2047 ExplorerBrowserImpl *eb;
2048 HRESULT ret;
2050 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
2052 if(!ppv)
2053 return E_POINTER;
2054 if(pUnkOuter)
2055 return CLASS_E_NOAGGREGATION;
2057 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
2058 eb->ref = 1;
2059 eb->IExplorerBrowser_iface.lpVtbl = &vt_IExplorerBrowser;
2060 eb->IShellBrowser_iface.lpVtbl = &vt_IShellBrowser;
2061 eb->ICommDlgBrowser3_iface.lpVtbl = &vt_ICommDlgBrowser3;
2062 eb->IObjectWithSite_iface.lpVtbl = &vt_IObjectWithSite;
2063 eb->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_INameSpaceTreeControlEvents;
2064 eb->IInputObject_iface.lpVtbl = &vt_IInputObject;
2066 /* Default settings */
2067 eb->navpane.width = 150;
2068 eb->navpane.show = TRUE;
2070 list_init(&eb->event_clients);
2071 list_init(&eb->travellog);
2073 ret = IExplorerBrowser_QueryInterface(&eb->IExplorerBrowser_iface, riid, ppv);
2074 IExplorerBrowser_Release(&eb->IExplorerBrowser_iface);
2076 TRACE("--(%p)\n", ppv);
2077 return ret;