dwrite: Ignore fonts with dot-prefixed names.
[wine.git] / dlls / shell32 / ebrowser.c
blobbbccf88814e0edf2ca909011b8f1bead59688071
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 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 rc = This->navpane.rc;
520 new_width = This->navpane.width + dx;
521 if(new_width > NP_MIN_WIDTH && This->sv_rc.right - new_width > SV_MIN_WIDTH)
523 rc.right = new_width;
524 rc.left = rc.right - SPLITTER_WIDTH;
525 splitter_draw(GetParent(hwnd), &This->splitter_rc);
526 splitter_draw(GetParent(hwnd), &rc);
527 This->splitter_rc = rc;
530 return TRUE;
533 static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
535 int new_width, dx;
537 if(GetCapture() != hwnd) return FALSE;
539 dx = (SHORT)LOWORD(lParam);
540 TRACE("%d.\n", dx);
542 splitter_draw(GetParent(hwnd), &This->splitter_rc);
544 new_width = This->navpane.width + dx;
545 if(new_width < NP_MIN_WIDTH)
546 new_width = NP_MIN_WIDTH;
547 else if(This->sv_rc.right - new_width < SV_MIN_WIDTH)
548 new_width = This->sv_rc.right - SV_MIN_WIDTH;
550 This->navpane.width = new_width;
552 update_layout(This);
553 size_panes(This);
555 ReleaseCapture();
557 return TRUE;
560 static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
562 ExplorerBrowserImpl *This = crs->lpCreateParams;
563 INameSpaceTreeControl2 *pnstc2;
564 DWORD style;
565 HRESULT hr;
567 TRACE("%p\n", This);
568 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LPARAM)This);
569 This->navpane.hwnd_splitter = hwnd;
571 hr = CoCreateInstance(&CLSID_NamespaceTreeControl, NULL, CLSCTX_INPROC_SERVER,
572 &IID_INameSpaceTreeControl2, (void**)&pnstc2);
574 if(SUCCEEDED(hr))
576 style = NSTCS_HASEXPANDOS | NSTCS_ROOTHASEXPANDO | NSTCS_SHOWSELECTIONALWAYS;
577 hr = INameSpaceTreeControl2_Initialize(pnstc2, GetParent(hwnd), NULL, style);
578 if(SUCCEEDED(hr))
580 INameSpaceTreeControlEvents *pnstce;
581 IShellFolder *psfdesktop;
582 IShellItem *psi;
583 IOleWindow *pow;
584 LPITEMIDLIST pidl;
585 DWORD cookie, style2 = NSTCS2_DISPLAYPADDING;
587 hr = INameSpaceTreeControl2_SetControlStyle2(pnstc2, 0xFF, style2);
588 if(FAILED(hr))
589 ERR("SetControlStyle2 failed (0x%08x)\n", hr);
591 hr = INameSpaceTreeControl2_QueryInterface(pnstc2, &IID_IOleWindow, (void**)&pow);
592 if(SUCCEEDED(hr))
594 IOleWindow_GetWindow(pow, &This->navpane.hwnd_nstc);
595 IOleWindow_Release(pow);
597 else
598 ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr);
600 pnstce = &This->INameSpaceTreeControlEvents_iface;
601 hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie);
602 if(FAILED(hr))
603 ERR("TreeAdvise failed. (0x%08x).\n", hr);
606 * Add the default roots
609 /* TODO: This should be FOLDERID_Links */
610 hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
611 if(SUCCEEDED(hr))
613 hr = SHCreateShellItem(NULL, NULL, pidl, &psi);
614 if(SUCCEEDED(hr))
616 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_NONFOLDERS, NSTCRS_VISIBLE, NULL);
617 IShellItem_Release(psi);
619 ILFree(pidl);
622 SHGetDesktopFolder(&psfdesktop);
623 hr = SHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
624 IShellFolder_Release(psfdesktop);
625 if(SUCCEEDED(hr))
627 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_FOLDERS, NSTCRS_EXPANDED, NULL);
628 IShellItem_Release(psi);
631 /* TODO:
632 * We should advertise IID_INameSpaceTreeControl to the site of the
633 * host through its IProfferService interface, if any.
636 This->navpane.pnstc2 = pnstc2;
637 This->navpane.nstc_cookie = cookie;
639 return TRUE;
643 This->navpane.pnstc2 = NULL;
644 ERR("Failed (0x%08x)\n", hr);
646 return FALSE;
649 static LRESULT navpane_on_wm_size_move(ExplorerBrowserImpl *This)
651 UINT height, width;
652 TRACE("%p\n", This);
654 width = This->navpane.rc.right - This->navpane.rc.left - SPLITTER_WIDTH;
655 height = This->navpane.rc.bottom - This->navpane.rc.top;
657 MoveWindow(This->navpane.hwnd_nstc,
658 This->navpane.rc.left, This->navpane.rc.top,
659 width, height,
660 TRUE);
662 return FALSE;
665 static LRESULT navpane_on_wm_destroy(ExplorerBrowserImpl *This)
667 INameSpaceTreeControl2_TreeUnadvise(This->navpane.pnstc2, This->navpane.nstc_cookie);
668 INameSpaceTreeControl2_Release(This->navpane.pnstc2);
669 This->navpane.pnstc2 = NULL;
670 return TRUE;
673 static LRESULT CALLBACK navpane_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
675 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
677 switch(uMessage) {
678 case WM_CREATE: return navpane_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
679 case WM_MOVE: /* Fall through */
680 case WM_SIZE: return navpane_on_wm_size_move(This);
681 case WM_DESTROY: return navpane_on_wm_destroy(This);
682 case WM_LBUTTONDOWN: return navpane_splitter_beginresize(This, hWnd, lParam);
683 case WM_MOUSEMOVE: return navpane_splitter_resizing(This, hWnd, lParam);
684 case WM_LBUTTONUP: return navpane_splitter_endresize(This, hWnd, lParam);
685 default:
686 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
688 return 0;
691 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc)
693 WNDCLASSW wc;
694 HWND splitter;
695 static const WCHAR navpane_classname[] = {'e','b','_','n','a','v','p','a','n','e',0};
697 if( !GetClassInfoW(shell32_hInstance, navpane_classname, &wc) )
699 wc.style = CS_HREDRAW | CS_VREDRAW;
700 wc.lpfnWndProc = navpane_wndproc;
701 wc.cbClsExtra = 0;
702 wc.cbWndExtra = 0;
703 wc.hInstance = shell32_hInstance;
704 wc.hIcon = 0;
705 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_SIZEWE);
706 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
707 wc.lpszMenuName = NULL;
708 wc.lpszClassName = navpane_classname;
710 if (!RegisterClassW(&wc)) return;
713 splitter = CreateWindowExW(0, navpane_classname, NULL,
714 WS_CHILD | WS_TABSTOP | WS_VISIBLE,
715 rc->right - SPLITTER_WIDTH, rc->top,
716 SPLITTER_WIDTH, rc->bottom - rc->top,
717 hwnd_parent, 0, shell32_hInstance, This);
718 if(!splitter)
719 ERR("Failed to create navpane : %d.\n", GetLastError());
722 /**************************************************************************
723 * Main window related functions.
725 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
727 ExplorerBrowserImpl *This = crs->lpCreateParams;
728 TRACE("%p\n", This);
730 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
731 This->hwnd_main = hWnd;
733 return TRUE;
736 static LRESULT main_on_wm_size(ExplorerBrowserImpl *This)
738 update_layout(This);
739 size_panes(This);
741 return TRUE;
744 static LRESULT main_on_cwm_getishellbrowser(ExplorerBrowserImpl *This)
746 return (LRESULT)&This->IShellBrowser_iface;
749 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
751 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
753 switch(uMessage)
755 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
756 case WM_SIZE: return main_on_wm_size(This);
757 case CWM_GETISHELLBROWSER: return main_on_cwm_getishellbrowser(This);
758 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
761 return 0;
764 /**************************************************************************
765 * IExplorerBrowser Implementation
768 static inline ExplorerBrowserImpl *impl_from_IExplorerBrowser(IExplorerBrowser *iface)
770 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IExplorerBrowser_iface);
773 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
774 REFIID riid, void **ppvObject)
776 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
777 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
779 *ppvObject = NULL;
780 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
781 IsEqualIID(riid, &IID_IUnknown))
783 *ppvObject = &This->IExplorerBrowser_iface;
785 else if(IsEqualIID(riid, &IID_IShellBrowser))
787 *ppvObject = &This->IShellBrowser_iface;
789 else if(IsEqualIID(riid, &IID_ICommDlgBrowser) ||
790 IsEqualIID(riid, &IID_ICommDlgBrowser2) ||
791 IsEqualIID(riid, &IID_ICommDlgBrowser3))
793 *ppvObject = &This->ICommDlgBrowser3_iface;
795 else if(IsEqualIID(riid, &IID_IObjectWithSite))
797 *ppvObject = &This->IObjectWithSite_iface;
799 else if(IsEqualIID(riid, &IID_IInputObject))
801 *ppvObject = &This->IInputObject_iface;
804 if(*ppvObject)
806 IUnknown_AddRef((IUnknown*)*ppvObject);
807 return S_OK;
810 return E_NOINTERFACE;
813 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
815 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
816 LONG ref = InterlockedIncrement(&This->ref);
817 TRACE("%p - ref %d\n", This, ref);
819 return ref;
822 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
824 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
825 LONG ref = InterlockedDecrement(&This->ref);
826 TRACE("%p - ref %d\n", This, ref);
828 if(!ref)
830 TRACE("Freeing.\n");
832 if(!This->destroyed)
833 IExplorerBrowser_Destroy(iface);
835 IObjectWithSite_SetSite(&This->IObjectWithSite_iface, NULL);
837 HeapFree(GetProcessHeap(), 0, This);
838 return 0;
841 return ref;
844 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
845 HWND hwndParent, const RECT *prc,
846 const FOLDERSETTINGS *pfs)
848 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
849 WNDCLASSW wc;
850 LONG style;
851 static const WCHAR EB_CLASS_NAME[] =
852 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
854 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
856 if(This->hwnd_main)
857 return E_UNEXPECTED;
859 if(!hwndParent)
860 return E_INVALIDARG;
862 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
864 wc.style = CS_HREDRAW | CS_VREDRAW;
865 wc.lpfnWndProc = main_wndproc;
866 wc.cbClsExtra = 0;
867 wc.cbWndExtra = 0;
868 wc.hInstance = shell32_hInstance;
869 wc.hIcon = 0;
870 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
871 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
872 wc.lpszMenuName = NULL;
873 wc.lpszClassName = EB_CLASS_NAME;
875 if (!RegisterClassW(&wc)) return E_FAIL;
878 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
879 if (!(This->eb_options & EBO_NOBORDER))
880 style |= WS_BORDER;
881 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
882 prc->left, prc->top,
883 prc->right - prc->left, prc->bottom - prc->top,
884 hwndParent, 0, shell32_hInstance, This);
886 if(!This->hwnd_main)
888 ERR("Failed to create the window.\n");
889 return E_FAIL;
892 This->fs.ViewMode = pfs ? pfs->ViewMode : FVM_DETAILS;
893 This->fs.fFlags = pfs ? (pfs->fFlags | FWF_NOCLIENTEDGE) : FWF_NOCLIENTEDGE;
895 return S_OK;
898 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
900 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
901 TRACE("%p\n", This);
903 if(This->psv)
905 IShellView_DestroyViewWindow(This->psv);
906 IShellView_Release(This->psv);
907 This->psv = NULL;
908 This->hwnd_sv = NULL;
911 events_unadvise_all(This);
912 travellog_remove_all_entries(This);
914 ILFree(This->current_pidl);
915 This->current_pidl = NULL;
917 DestroyWindow(This->hwnd_main);
918 This->destroyed = TRUE;
920 return S_OK;
923 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
924 HDWP *phdwp, RECT rcBrowser)
926 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
927 TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
929 if(phdwp && *phdwp)
931 *phdwp = DeferWindowPos(*phdwp, This->hwnd_main, NULL, rcBrowser.left, rcBrowser.top,
932 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top,
933 SWP_NOZORDER | SWP_NOACTIVATE);
934 if(!*phdwp)
935 return E_FAIL;
937 else
939 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
940 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
943 return S_OK;
946 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
947 LPCWSTR pszPropertyBag)
949 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
950 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
952 if(!pszPropertyBag)
953 return E_INVALIDARG;
955 /* FIXME: This method is currently useless as we don't save any
956 * settings anywhere, but at least one application breaks if we
957 * return E_NOTIMPL.
960 return S_OK;
963 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
964 LPCWSTR pszEmptyText)
966 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
967 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
969 return E_NOTIMPL;
972 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
973 const FOLDERSETTINGS *pfs)
975 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
976 TRACE("%p (%p)\n", This, pfs);
978 if(!pfs)
979 return E_INVALIDARG;
981 This->fs.ViewMode = pfs->ViewMode;
982 This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
984 /* Change the settings of the current view, if any. */
985 return change_viewmode(This, This->fs.ViewMode);
988 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
989 IExplorerBrowserEvents *psbe,
990 DWORD *pdwCookie)
992 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
993 event_client *client;
994 TRACE("%p (%p, %p)\n", This, psbe, pdwCookie);
996 client = HeapAlloc(GetProcessHeap(), 0, sizeof(event_client));
997 client->pebe = psbe;
998 client->cookie = ++This->events_next_cookie;
1000 IExplorerBrowserEvents_AddRef(psbe);
1001 *pdwCookie = client->cookie;
1003 list_add_tail(&This->event_clients, &client->entry);
1005 return S_OK;
1008 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
1009 DWORD dwCookie)
1011 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1012 event_client *client;
1013 TRACE("%p (0x%x)\n", This, dwCookie);
1015 LIST_FOR_EACH_ENTRY(client, &This->event_clients, event_client, entry)
1017 if(client->cookie == dwCookie)
1019 list_remove(&client->entry);
1020 IExplorerBrowserEvents_Release(client->pebe);
1021 HeapFree(GetProcessHeap(), 0, client);
1022 return S_OK;
1026 return E_INVALIDARG;
1029 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
1030 EXPLORER_BROWSER_OPTIONS dwFlag)
1032 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1033 static const EXPLORER_BROWSER_OPTIONS unsupported_options =
1034 EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW | EBO_NOPERSISTVIEWSTATE;
1036 TRACE("%p (0x%x)\n", This, dwFlag);
1038 if(dwFlag & unsupported_options)
1039 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag);
1041 This->eb_options = dwFlag;
1043 return S_OK;
1046 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
1047 EXPLORER_BROWSER_OPTIONS *pdwFlag)
1049 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1050 TRACE("%p (%p)\n", This, pdwFlag);
1052 *pdwFlag = This->eb_options;
1054 return S_OK;
1057 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
1058 PCUIDLIST_RELATIVE pidl,
1059 UINT uFlags)
1061 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1062 LPITEMIDLIST absolute_pidl = NULL;
1063 HRESULT hr;
1064 static const UINT unsupported_browse_flags =
1065 SBSP_NEWBROWSER | EBF_SELECTFROMDATAOBJECT | EBF_NODROPTARGET;
1066 TRACE("%p (%p, 0x%x)\n", This, pidl, uFlags);
1068 if(!This->hwnd_main)
1069 return E_FAIL;
1071 if(This->destroyed)
1072 return HRESULT_FROM_WIN32(ERROR_BUSY);
1074 if(This->current_pidl && (This->eb_options & EBO_NAVIGATEONCE))
1075 return E_FAIL;
1077 if(uFlags & SBSP_EXPLOREMODE)
1078 return E_INVALIDARG;
1080 if(uFlags & unsupported_browse_flags)
1081 FIXME("Argument 0x%x contains unsupported flags.\n", uFlags);
1083 if(uFlags & SBSP_NAVIGATEBACK)
1085 TRACE("SBSP_NAVIGATEBACK\n");
1086 absolute_pidl = ILClone(travellog_go_back(This));
1087 if(!absolute_pidl && !This->current_pidl)
1088 return E_FAIL;
1089 else if(!absolute_pidl)
1090 return S_OK;
1093 else if(uFlags & SBSP_NAVIGATEFORWARD)
1095 TRACE("SBSP_NAVIGATEFORWARD\n");
1096 absolute_pidl = ILClone(travellog_go_forward(This));
1097 if(!absolute_pidl && !This->current_pidl)
1098 return E_FAIL;
1099 else if(!absolute_pidl)
1100 return S_OK;
1103 else if(uFlags & SBSP_PARENT)
1105 if(This->current_pidl)
1107 if(_ILIsPidlSimple(This->current_pidl))
1109 absolute_pidl = _ILCreateDesktop();
1111 else
1113 absolute_pidl = ILClone(This->current_pidl);
1114 ILRemoveLastID(absolute_pidl);
1117 if(!absolute_pidl)
1119 ERR("Failed to get parent pidl.\n");
1120 return E_FAIL;
1124 else if(uFlags & SBSP_RELATIVE)
1126 /* SBSP_RELATIVE has precedence over SBSP_ABSOLUTE */
1127 TRACE("SBSP_RELATIVE\n");
1128 if(This->current_pidl)
1130 absolute_pidl = ILCombine(This->current_pidl, pidl);
1132 if(!absolute_pidl)
1134 ERR("Failed to get absolute pidl.\n");
1135 return E_FAIL;
1138 else
1140 TRACE("SBSP_ABSOLUTE\n");
1141 absolute_pidl = ILClone(pidl);
1142 if(!absolute_pidl && !This->current_pidl)
1143 return E_INVALIDARG;
1144 else if(!absolute_pidl)
1145 return S_OK;
1148 /* TODO: Asynchronous browsing. Return S_OK here and finish in
1149 * another thread. */
1151 hr = events_NavigationPending(This, absolute_pidl);
1152 if(FAILED(hr))
1154 TRACE("Browsing aborted.\n");
1155 ILFree(absolute_pidl);
1156 return E_FAIL;
1159 get_interfaces_from_site(This);
1160 update_panestate(This);
1162 /* Only browse if the new pidl differs from the old */
1163 if(!ILIsEqual(This->current_pidl, absolute_pidl))
1165 IShellItem *psi;
1166 hr = SHCreateItemFromIDList(absolute_pidl, &IID_IShellItem, (void**)&psi);
1167 if(SUCCEEDED(hr))
1169 hr = create_new_shellview(This, psi);
1170 if(FAILED(hr))
1172 events_NavigationFailed(This, absolute_pidl);
1173 ILFree(absolute_pidl);
1174 IShellItem_Release(psi);
1175 return E_FAIL;
1178 /* Add to travellog */
1179 if( !(This->eb_options & EBO_NOTRAVELLOG) &&
1180 !(uFlags & (SBSP_NAVIGATEFORWARD|SBSP_NAVIGATEBACK)) )
1182 travellog_add_entry(This, absolute_pidl);
1185 IShellItem_Release(psi);
1189 events_NavigationComplete(This, absolute_pidl);
1190 ILFree(This->current_pidl);
1191 This->current_pidl = absolute_pidl;
1193 /* Expand the NameSpaceTree to the current location. */
1194 if(This->navpane.show && This->navpane.pnstc2)
1196 IShellItem *psi;
1197 hr = SHCreateItemFromIDList(This->current_pidl, &IID_IShellItem, (void**)&psi);
1198 if(SUCCEEDED(hr))
1200 INameSpaceTreeControl2_EnsureItemVisible(This->navpane.pnstc2, psi);
1201 IShellItem_Release(psi);
1205 return S_OK;
1208 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
1209 IUnknown *punk, UINT uFlags)
1211 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1212 LPITEMIDLIST pidl;
1213 HRESULT hr;
1214 TRACE("%p (%p, 0x%x)\n", This, punk, uFlags);
1216 if(!punk)
1217 return IExplorerBrowser_BrowseToIDList(iface, NULL, uFlags);
1219 hr = SHGetIDListFromObject(punk, &pidl);
1220 if(SUCCEEDED(hr))
1222 hr = IExplorerBrowser_BrowseToIDList(iface, pidl, uFlags);
1223 ILFree(pidl);
1226 return hr;
1229 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
1230 IUnknown *punk,
1231 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
1233 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1234 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
1236 return E_NOTIMPL;
1239 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
1241 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1242 FIXME("stub, %p\n", This);
1244 return E_NOTIMPL;
1247 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
1248 REFIID riid, void **ppv)
1250 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1251 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
1253 if(!This->psv)
1254 return E_FAIL;
1256 return IShellView_QueryInterface(This->psv, riid, ppv);
1259 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
1261 IExplorerBrowser_fnQueryInterface,
1262 IExplorerBrowser_fnAddRef,
1263 IExplorerBrowser_fnRelease,
1264 IExplorerBrowser_fnInitialize,
1265 IExplorerBrowser_fnDestroy,
1266 IExplorerBrowser_fnSetRect,
1267 IExplorerBrowser_fnSetPropertyBag,
1268 IExplorerBrowser_fnSetEmptyText,
1269 IExplorerBrowser_fnSetFolderSettings,
1270 IExplorerBrowser_fnAdvise,
1271 IExplorerBrowser_fnUnadvise,
1272 IExplorerBrowser_fnSetOptions,
1273 IExplorerBrowser_fnGetOptions,
1274 IExplorerBrowser_fnBrowseToIDList,
1275 IExplorerBrowser_fnBrowseToObject,
1276 IExplorerBrowser_fnFillFromObject,
1277 IExplorerBrowser_fnRemoveAll,
1278 IExplorerBrowser_fnGetCurrentView
1281 /**************************************************************************
1282 * IShellBrowser Implementation
1285 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
1287 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IShellBrowser_iface);
1290 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
1291 REFIID riid, void **ppvObject)
1293 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1294 TRACE("%p\n", This);
1295 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1298 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
1300 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1301 TRACE("%p\n", This);
1302 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1305 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
1307 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1308 TRACE("%p\n", This);
1309 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1312 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
1314 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1315 TRACE("%p (%p)\n", This, phwnd);
1317 if(!This->hwnd_main)
1318 return E_FAIL;
1320 *phwnd = This->hwnd_main;
1321 return S_OK;
1324 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
1325 BOOL fEnterMode)
1327 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1328 FIXME("stub, %p (%d)\n", This, fEnterMode);
1330 return E_NOTIMPL;
1333 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
1334 HMENU hmenuShared,
1335 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1337 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1338 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
1340 /* Not implemented. */
1341 return E_NOTIMPL;
1344 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
1345 HMENU hmenuShared,
1346 HOLEMENU holemenuReserved,
1347 HWND hwndActiveObject)
1349 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1350 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
1352 /* Not implemented. */
1353 return E_NOTIMPL;
1356 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
1357 HMENU hmenuShared)
1359 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1360 TRACE("%p (%p)\n", This, hmenuShared);
1362 /* Not implemented. */
1363 return E_NOTIMPL;
1366 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
1367 LPCOLESTR pszStatusText)
1369 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1370 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
1372 return E_NOTIMPL;
1375 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
1376 BOOL fEnable)
1378 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1379 FIXME("stub, %p (%d)\n", This, fEnable);
1381 return E_NOTIMPL;
1384 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
1385 MSG *pmsg, WORD wID)
1387 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1388 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
1390 return E_NOTIMPL;
1393 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
1394 LPCITEMIDLIST pidl, UINT wFlags)
1396 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1397 TRACE("%p (%p, %x)\n", This, pidl, wFlags);
1399 return IExplorerBrowser_BrowseToIDList(&This->IExplorerBrowser_iface, pidl, wFlags);
1402 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
1403 DWORD grfMode,
1404 IStream **ppStrm)
1406 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1407 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
1409 *ppStrm = NULL;
1410 return E_FAIL;
1413 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
1414 UINT id, HWND *phwnd)
1416 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1417 TRACE("(%p)->(%d, %p)\n", This, id, phwnd);
1418 if (phwnd) *phwnd = NULL;
1419 return E_NOTIMPL;
1422 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
1423 UINT id, UINT uMsg,
1424 WPARAM wParam, LPARAM lParam,
1425 LRESULT *pret)
1427 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1428 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
1430 return E_NOTIMPL;
1433 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
1434 IShellView **ppshv)
1436 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1437 TRACE("%p (%p)\n", This, ppshv);
1439 if(!This->psv)
1440 return E_FAIL;
1442 *ppshv = This->psv;
1443 IShellView_AddRef(This->psv);
1445 return S_OK;
1448 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
1449 IShellView *pshv)
1451 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1452 FIXME("stub, %p (%p)\n", This, pshv);
1454 return E_NOTIMPL;
1457 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
1458 LPTBBUTTONSB lpButtons,
1459 UINT nButtons, UINT uFlags)
1461 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1462 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
1464 return E_NOTIMPL;
1467 static const IShellBrowserVtbl vt_IShellBrowser = {
1468 IShellBrowser_fnQueryInterface,
1469 IShellBrowser_fnAddRef,
1470 IShellBrowser_fnRelease,
1471 IShellBrowser_fnGetWindow,
1472 IShellBrowser_fnContextSensitiveHelp,
1473 IShellBrowser_fnInsertMenusSB,
1474 IShellBrowser_fnSetMenuSB,
1475 IShellBrowser_fnRemoveMenusSB,
1476 IShellBrowser_fnSetStatusTextSB,
1477 IShellBrowser_fnEnableModelessSB,
1478 IShellBrowser_fnTranslateAcceleratorSB,
1479 IShellBrowser_fnBrowseObject,
1480 IShellBrowser_fnGetViewStateStream,
1481 IShellBrowser_fnGetControlWindow,
1482 IShellBrowser_fnSendControlMsg,
1483 IShellBrowser_fnQueryActiveShellView,
1484 IShellBrowser_fnOnViewWindowActive,
1485 IShellBrowser_fnSetToolbarItems
1488 /**************************************************************************
1489 * ICommDlgBrowser3 Implementation
1492 static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
1494 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, ICommDlgBrowser3_iface);
1497 static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface,
1498 REFIID riid,
1499 void **ppvObject)
1501 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1502 TRACE("%p\n", This);
1503 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1506 static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
1508 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1509 TRACE("%p\n", This);
1510 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1513 static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
1515 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1516 TRACE("%p\n", This);
1517 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1520 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *iface,
1521 IShellView *shv)
1523 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1524 IDataObject *pdo;
1525 HRESULT hr;
1526 HRESULT ret = S_FALSE;
1528 TRACE("%p (%p)\n", This, shv);
1530 hr = IShellView_GetItemObject(shv, SVGIO_SELECTION, &IID_IDataObject, (void**)&pdo);
1531 if(SUCCEEDED(hr))
1533 FORMATETC fmt;
1534 STGMEDIUM medium;
1536 fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
1537 fmt.ptd = NULL;
1538 fmt.dwAspect = DVASPECT_CONTENT;
1539 fmt.lindex = -1;
1540 fmt.tymed = TYMED_HGLOBAL;
1542 hr = IDataObject_GetData(pdo, &fmt ,&medium);
1543 IDataObject_Release(pdo);
1544 if(SUCCEEDED(hr))
1546 LPIDA pida = GlobalLock(medium.u.hGlobal);
1547 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
1549 /* Handle folders by browsing to them. */
1550 if(_ILIsFolder(pidl_child) || _ILIsDrive(pidl_child) || _ILIsSpecialFolder(pidl_child))
1552 IExplorerBrowser_BrowseToIDList(&This->IExplorerBrowser_iface, pidl_child, SBSP_RELATIVE);
1553 ret = S_OK;
1555 GlobalUnlock(medium.u.hGlobal);
1556 GlobalFree(medium.u.hGlobal);
1558 else
1559 ERR("Failed to get data from IDataObject.\n");
1560 } else
1561 ERR("Failed to get IDataObject.\n");
1563 /* If we didn't handle the default command, check if we have a
1564 * client that does */
1565 if(ret == S_FALSE && This->pcdb_site)
1566 return ICommDlgBrowser_OnDefaultCommand(This->pcdb_site, shv);
1568 return ret;
1570 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface,
1571 IShellView *shv, ULONG uChange)
1573 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1574 TRACE("%p (%p, %d)\n", This, shv, uChange);
1576 if(This->pcdb_site)
1577 return ICommDlgBrowser_OnStateChange(This->pcdb_site, shv, uChange);
1579 return E_NOTIMPL;
1581 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
1582 IShellView *pshv, LPCITEMIDLIST pidl)
1584 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1585 TRACE("%p (%p, %p)\n", This, pshv, pidl);
1587 if(This->pcdb_site)
1588 return ICommDlgBrowser_IncludeObject(This->pcdb_site, pshv, pidl);
1590 return S_OK;
1593 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
1594 IShellView *pshv,
1595 DWORD dwNotifyType)
1597 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1598 TRACE("%p (%p, 0x%x)\n", This, pshv, dwNotifyType);
1600 if(This->pcdb2_site)
1601 return ICommDlgBrowser2_Notify(This->pcdb2_site, pshv, dwNotifyType);
1603 return S_OK;
1606 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(ICommDlgBrowser3 *iface,
1607 IShellView *pshv,
1608 LPWSTR pszText, int cchMax)
1610 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1611 TRACE("%p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
1613 if(This->pcdb2_site)
1614 return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb2_site, pshv, pszText, cchMax);
1616 return S_OK;
1619 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(ICommDlgBrowser3 *iface,
1620 DWORD *pdwFlags)
1622 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1623 TRACE("%p (%p)\n", This, pdwFlags);
1625 if(This->pcdb2_site)
1626 return ICommDlgBrowser2_GetViewFlags(This->pcdb2_site, pdwFlags);
1628 return S_OK;
1631 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(ICommDlgBrowser3 *iface,
1632 IShellView *pshv, int iColumn)
1634 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1635 TRACE("%p (%p, %d)\n", This, pshv, iColumn);
1637 if(This->pcdb3_site)
1638 return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
1640 return S_OK;
1643 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(ICommDlgBrowser3 *iface,
1644 LPWSTR pszFileSpec,
1645 int cchFileSpec)
1647 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1648 TRACE("%p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
1650 if(This->pcdb3_site)
1651 return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
1653 return S_OK;
1656 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(ICommDlgBrowser3 *iface,
1657 IShellView *pshv)
1659 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1660 TRACE("%p (%p)\n", This, pshv);
1662 if(This->pcdb3_site)
1663 return ICommDlgBrowser3_OnPreviewCreated(This->pcdb3_site, pshv);
1665 return S_OK;
1668 static const ICommDlgBrowser3Vtbl vt_ICommDlgBrowser3 = {
1669 ICommDlgBrowser3_fnQueryInterface,
1670 ICommDlgBrowser3_fnAddRef,
1671 ICommDlgBrowser3_fnRelease,
1672 ICommDlgBrowser3_fnOnDefaultCommand,
1673 ICommDlgBrowser3_fnOnStateChange,
1674 ICommDlgBrowser3_fnIncludeObject,
1675 ICommDlgBrowser3_fnNotify,
1676 ICommDlgBrowser3_fnGetDefaultMenuText,
1677 ICommDlgBrowser3_fnGetViewFlags,
1678 ICommDlgBrowser3_fnOnColumnClicked,
1679 ICommDlgBrowser3_fnGetCurrentFilter,
1680 ICommDlgBrowser3_fnOnPreviewCreated
1683 /**************************************************************************
1684 * IObjectWithSite Implementation
1687 static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
1689 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IObjectWithSite_iface);
1692 static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface,
1693 REFIID riid, void **ppvObject)
1695 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1696 TRACE("%p\n", This);
1697 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1700 static ULONG WINAPI IObjectWithSite_fnAddRef(IObjectWithSite *iface)
1702 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1703 TRACE("%p\n", This);
1704 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1707 static ULONG WINAPI IObjectWithSite_fnRelease(IObjectWithSite *iface)
1709 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1710 TRACE("%p\n", This);
1711 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1714 static HRESULT WINAPI IObjectWithSite_fnSetSite(IObjectWithSite *iface, IUnknown *punk_site)
1716 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1717 TRACE("%p (%p)\n", This, punk_site);
1719 if(This->punk_site)
1721 IUnknown_Release(This->punk_site);
1722 This->punk_site = NULL;
1723 get_interfaces_from_site(This);
1726 This->punk_site = punk_site;
1728 if(This->punk_site)
1729 IUnknown_AddRef(This->punk_site);
1731 return S_OK;
1734 static HRESULT WINAPI IObjectWithSite_fnGetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite)
1736 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1737 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvSite);
1739 if(!This->punk_site)
1740 return E_FAIL;
1742 return IUnknown_QueryInterface(This->punk_site, riid, ppvSite);
1745 static const IObjectWithSiteVtbl vt_IObjectWithSite = {
1746 IObjectWithSite_fnQueryInterface,
1747 IObjectWithSite_fnAddRef,
1748 IObjectWithSite_fnRelease,
1749 IObjectWithSite_fnSetSite,
1750 IObjectWithSite_fnGetSite
1753 /**************************************************************************
1754 * INameSpaceTreeControlEvents Implementation
1756 static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
1758 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, INameSpaceTreeControlEvents_iface);
1761 static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface,
1762 REFIID riid, void **ppvObject)
1764 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1765 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
1767 *ppvObject = NULL;
1768 if(IsEqualIID(riid, &IID_INameSpaceTreeControlEvents) ||
1769 IsEqualIID(riid, &IID_IUnknown))
1771 *ppvObject = iface;
1774 if(*ppvObject)
1776 IUnknown_AddRef((IUnknown*)*ppvObject);
1777 return S_OK;
1780 return E_NOINTERFACE;
1783 static ULONG WINAPI NSTCEvents_fnAddRef(INameSpaceTreeControlEvents *iface)
1785 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1786 TRACE("%p\n", This);
1787 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1790 static ULONG WINAPI NSTCEvents_fnRelease(INameSpaceTreeControlEvents *iface)
1792 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1793 TRACE("%p\n", This);
1794 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1797 static HRESULT WINAPI NSTCEvents_fnOnItemClick(INameSpaceTreeControlEvents *iface,
1798 IShellItem *psi,
1799 NSTCEHITTEST nstceHitTest,
1800 NSTCECLICKTYPE nstceClickType)
1802 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1803 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstceHitTest, nstceClickType);
1804 return S_OK;
1807 static HRESULT WINAPI NSTCEvents_fnOnPropertyItemCommit(INameSpaceTreeControlEvents *iface,
1808 IShellItem *psi)
1810 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1811 TRACE("%p (%p)\n", This, psi);
1812 return E_NOTIMPL;
1815 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanging(INameSpaceTreeControlEvents *iface,
1816 IShellItem *psi,
1817 NSTCITEMSTATE nstcisMask,
1818 NSTCITEMSTATE nstcisState)
1820 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1821 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1822 return E_NOTIMPL;
1825 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanged(INameSpaceTreeControlEvents *iface,
1826 IShellItem *psi,
1827 NSTCITEMSTATE nstcisMask,
1828 NSTCITEMSTATE nstcisState)
1830 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1831 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1832 return E_NOTIMPL;
1835 static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(INameSpaceTreeControlEvents *iface,
1836 IShellItemArray *psiaSelection)
1838 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1839 IShellItem *psi;
1840 HRESULT hr;
1841 TRACE("%p (%p)\n", This, psiaSelection);
1843 hr = IShellItemArray_GetItemAt(psiaSelection, 0, &psi);
1844 if(SUCCEEDED(hr))
1846 hr = IExplorerBrowser_BrowseToObject(&This->IExplorerBrowser_iface,
1847 (IUnknown*)psi, SBSP_DEFBROWSER);
1848 IShellItem_Release(psi);
1851 return hr;
1854 static HRESULT WINAPI NSTCEvents_fnOnKeyboardInput(INameSpaceTreeControlEvents *iface,
1855 UINT uMsg, WPARAM wParam, LPARAM lParam)
1857 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1858 TRACE("%p (%d, 0x%lx, 0x%lx)\n", This, uMsg, wParam, lParam);
1859 return S_OK;
1862 static HRESULT WINAPI NSTCEvents_fnOnBeforeExpand(INameSpaceTreeControlEvents *iface,
1863 IShellItem *psi)
1865 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1866 TRACE("%p (%p)\n", This, psi);
1867 return E_NOTIMPL;
1870 static HRESULT WINAPI NSTCEvents_fnOnAfterExpand(INameSpaceTreeControlEvents *iface,
1871 IShellItem *psi)
1873 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1874 TRACE("%p (%p)\n", This, psi);
1875 return E_NOTIMPL;
1878 static HRESULT WINAPI NSTCEvents_fnOnBeginLabelEdit(INameSpaceTreeControlEvents *iface,
1879 IShellItem *psi)
1881 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1882 TRACE("%p (%p)\n", This, psi);
1883 return E_NOTIMPL;
1886 static HRESULT WINAPI NSTCEvents_fnOnEndLabelEdit(INameSpaceTreeControlEvents *iface,
1887 IShellItem *psi)
1889 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1890 TRACE("%p (%p)\n", This, psi);
1891 return E_NOTIMPL;
1894 static HRESULT WINAPI NSTCEvents_fnOnGetToolTip(INameSpaceTreeControlEvents *iface,
1895 IShellItem *psi, LPWSTR pszTip, int cchTip)
1897 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1898 TRACE("%p (%p, %p, %d)\n", This, psi, pszTip, cchTip);
1899 return E_NOTIMPL;
1902 static HRESULT WINAPI NSTCEvents_fnOnBeforeItemDelete(INameSpaceTreeControlEvents *iface,
1903 IShellItem *psi)
1905 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1906 TRACE("%p (%p)\n", This, psi);
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI NSTCEvents_fnOnItemAdded(INameSpaceTreeControlEvents *iface,
1911 IShellItem *psi, BOOL fIsRoot)
1913 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1914 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1915 return E_NOTIMPL;
1918 static HRESULT WINAPI NSTCEvents_fnOnItemDeleted(INameSpaceTreeControlEvents *iface,
1919 IShellItem *psi, BOOL fIsRoot)
1921 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1922 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1923 return E_NOTIMPL;
1926 static HRESULT WINAPI NSTCEvents_fnOnBeforeContextMenu(INameSpaceTreeControlEvents *iface,
1927 IShellItem *psi, REFIID riid, void **ppv)
1929 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1930 TRACE("%p (%p, %s, %p)\n", This, psi, shdebugstr_guid(riid), ppv);
1931 return E_NOTIMPL;
1934 static HRESULT WINAPI NSTCEvents_fnOnAfterContextMenu(INameSpaceTreeControlEvents *iface,
1935 IShellItem *psi, IContextMenu *pcmIn,
1936 REFIID riid, void **ppv)
1938 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1939 TRACE("%p (%p, %p, %s, %p)\n", This, psi, pcmIn, shdebugstr_guid(riid), ppv);
1940 return E_NOTIMPL;
1943 static HRESULT WINAPI NSTCEvents_fnOnBeforeStateImageChange(INameSpaceTreeControlEvents *iface,
1944 IShellItem *psi)
1946 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1947 TRACE("%p (%p)\n", This, psi);
1948 return E_NOTIMPL;
1951 static HRESULT WINAPI NSTCEvents_fnOnGetDefaultIconIndex(INameSpaceTreeControlEvents* iface,
1952 IShellItem *psi,
1953 int *piDefaultIcon, int *piOpenIcon)
1955 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1956 TRACE("%p (%p, %p, %p)\n", This, psi, piDefaultIcon, piOpenIcon);
1957 return E_NOTIMPL;
1961 static const INameSpaceTreeControlEventsVtbl vt_INameSpaceTreeControlEvents = {
1962 NSTCEvents_fnQueryInterface,
1963 NSTCEvents_fnAddRef,
1964 NSTCEvents_fnRelease,
1965 NSTCEvents_fnOnItemClick,
1966 NSTCEvents_fnOnPropertyItemCommit,
1967 NSTCEvents_fnOnItemStateChanging,
1968 NSTCEvents_fnOnItemStateChanged,
1969 NSTCEvents_fnOnSelectionChanged,
1970 NSTCEvents_fnOnKeyboardInput,
1971 NSTCEvents_fnOnBeforeExpand,
1972 NSTCEvents_fnOnAfterExpand,
1973 NSTCEvents_fnOnBeginLabelEdit,
1974 NSTCEvents_fnOnEndLabelEdit,
1975 NSTCEvents_fnOnGetToolTip,
1976 NSTCEvents_fnOnBeforeItemDelete,
1977 NSTCEvents_fnOnItemAdded,
1978 NSTCEvents_fnOnItemDeleted,
1979 NSTCEvents_fnOnBeforeContextMenu,
1980 NSTCEvents_fnOnAfterContextMenu,
1981 NSTCEvents_fnOnBeforeStateImageChange,
1982 NSTCEvents_fnOnGetDefaultIconIndex
1985 /**************************************************************************
1986 * IInputObject Implementation
1989 static inline ExplorerBrowserImpl *impl_from_IInputObject(IInputObject *iface)
1991 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IInputObject_iface);
1994 static HRESULT WINAPI IInputObject_fnQueryInterface(IInputObject *iface,
1995 REFIID riid, void **ppvObject)
1997 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
1998 TRACE("%p\n", This);
1999 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
2002 static ULONG WINAPI IInputObject_fnAddRef(IInputObject *iface)
2004 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2005 TRACE("%p\n", This);
2006 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
2009 static ULONG WINAPI IInputObject_fnRelease(IInputObject *iface)
2011 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2012 TRACE("%p\n", This);
2013 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
2016 static HRESULT WINAPI IInputObject_fnUIActivateIO(IInputObject *iface, BOOL fActivate, MSG *pMsg)
2018 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2019 FIXME("stub, %p (%d, %p)\n", This, fActivate, pMsg);
2020 return E_NOTIMPL;
2023 static HRESULT WINAPI IInputObject_fnHasFocusIO(IInputObject *iface)
2025 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2026 FIXME("stub, %p\n", This);
2027 return E_NOTIMPL;
2030 static HRESULT WINAPI IInputObject_fnTranslateAcceleratorIO(IInputObject *iface, MSG *pMsg)
2032 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2033 FIXME("stub, %p (%p)\n", This, pMsg);
2034 return E_NOTIMPL;
2037 static IInputObjectVtbl vt_IInputObject = {
2038 IInputObject_fnQueryInterface,
2039 IInputObject_fnAddRef,
2040 IInputObject_fnRelease,
2041 IInputObject_fnUIActivateIO,
2042 IInputObject_fnHasFocusIO,
2043 IInputObject_fnTranslateAcceleratorIO
2046 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
2048 ExplorerBrowserImpl *eb;
2049 HRESULT ret;
2051 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
2053 if(!ppv)
2054 return E_POINTER;
2055 if(pUnkOuter)
2056 return CLASS_E_NOAGGREGATION;
2058 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
2059 eb->ref = 1;
2060 eb->IExplorerBrowser_iface.lpVtbl = &vt_IExplorerBrowser;
2061 eb->IShellBrowser_iface.lpVtbl = &vt_IShellBrowser;
2062 eb->ICommDlgBrowser3_iface.lpVtbl = &vt_ICommDlgBrowser3;
2063 eb->IObjectWithSite_iface.lpVtbl = &vt_IObjectWithSite;
2064 eb->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_INameSpaceTreeControlEvents;
2065 eb->IInputObject_iface.lpVtbl = &vt_IInputObject;
2067 /* Default settings */
2068 eb->navpane.width = 150;
2069 eb->navpane.show = TRUE;
2071 list_init(&eb->event_clients);
2072 list_init(&eb->travellog);
2074 ret = IExplorerBrowser_QueryInterface(&eb->IExplorerBrowser_iface, riid, ppv);
2075 IExplorerBrowser_Release(&eb->IExplorerBrowser_iface);
2077 TRACE("--(%p)\n", ppv);
2078 return ret;