wined3d: Handle 3D textures in wined3d_device_copy_sub_resource_region().
[wine.git] / dlls / shell32 / ebrowser.c
blob2d5a30aabbc4af302d686a9f852bb476a1677649
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 NP_DEFAULT_WIDTH 150
42 #define SV_MIN_WIDTH 150
44 typedef struct _event_client {
45 struct list entry;
46 IExplorerBrowserEvents *pebe;
47 DWORD cookie;
48 } event_client;
50 typedef struct _travellog_entry {
51 struct list entry;
52 LPITEMIDLIST pidl;
53 } travellog_entry;
55 typedef struct _ExplorerBrowserImpl {
56 IExplorerBrowser IExplorerBrowser_iface;
57 IShellBrowser IShellBrowser_iface;
58 ICommDlgBrowser3 ICommDlgBrowser3_iface;
59 IObjectWithSite IObjectWithSite_iface;
60 INameSpaceTreeControlEvents INameSpaceTreeControlEvents_iface;
61 IInputObject IInputObject_iface;
62 LONG ref;
63 BOOL destroyed;
65 HWND hwnd_main;
66 HWND hwnd_sv;
68 RECT splitter_rc;
69 struct {
70 INameSpaceTreeControl2 *pnstc2;
71 HWND hwnd_splitter, hwnd_nstc;
72 DWORD nstc_cookie;
73 UINT width;
74 BOOL show;
75 RECT rc;
76 } navpane;
78 EXPLORER_BROWSER_OPTIONS eb_options;
79 FOLDERSETTINGS fs;
81 struct list event_clients;
82 DWORD events_next_cookie;
83 struct list travellog;
84 travellog_entry *travellog_cursor;
85 int travellog_count;
87 int dpix;
89 IShellView *psv;
90 RECT sv_rc;
91 LPITEMIDLIST current_pidl;
93 IUnknown *punk_site;
94 ICommDlgBrowser *pcdb_site;
95 ICommDlgBrowser2 *pcdb2_site;
96 ICommDlgBrowser3 *pcdb3_site;
97 IExplorerPaneVisibility *pepv_site;
98 } ExplorerBrowserImpl;
100 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc);
102 /**************************************************************************
103 * Event functions.
105 static void events_unadvise_all(ExplorerBrowserImpl *This)
107 event_client *client, *curs;
108 TRACE("%p\n", This);
110 LIST_FOR_EACH_ENTRY_SAFE(client, curs, &This->event_clients, event_client, entry)
112 TRACE("Removing %p\n", client);
113 list_remove(&client->entry);
114 IExplorerBrowserEvents_Release(client->pebe);
115 heap_free(client);
119 static HRESULT events_NavigationPending(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
121 event_client *cursor;
122 HRESULT hres = S_OK;
124 TRACE("%p\n", This);
126 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
128 TRACE("Notifying %p\n", cursor);
129 hres = IExplorerBrowserEvents_OnNavigationPending(cursor->pebe, pidl);
131 /* If this failed for any reason, the browsing is supposed to be aborted. */
132 if(FAILED(hres))
133 break;
136 return hres;
139 static void events_NavigationComplete(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
141 event_client *cursor;
143 TRACE("%p\n", This);
145 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
147 TRACE("Notifying %p\n", cursor);
148 IExplorerBrowserEvents_OnNavigationComplete(cursor->pebe, pidl);
152 static void events_NavigationFailed(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
154 event_client *cursor;
156 TRACE("%p\n", This);
158 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
160 TRACE("Notifying %p\n", cursor);
161 IExplorerBrowserEvents_OnNavigationFailed(cursor->pebe, pidl);
165 static void events_ViewCreated(ExplorerBrowserImpl *This, IShellView *psv)
167 event_client *cursor;
169 TRACE("%p\n", This);
171 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
173 TRACE("Notifying %p\n", cursor);
174 IExplorerBrowserEvents_OnViewCreated(cursor->pebe, psv);
178 /**************************************************************************
179 * Travellog functions.
181 static void travellog_remove_entry(ExplorerBrowserImpl *This, travellog_entry *entry)
183 TRACE("Removing %p\n", entry);
185 list_remove(&entry->entry);
186 ILFree(entry->pidl);
187 heap_free(entry);
188 This->travellog_count--;
191 static void travellog_remove_all_entries(ExplorerBrowserImpl *This)
193 travellog_entry *cursor, *cursor2;
194 TRACE("%p\n", This);
196 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
197 travellog_remove_entry(This, cursor);
199 This->travellog_cursor = NULL;
202 static void travellog_add_entry(ExplorerBrowserImpl *This, LPITEMIDLIST pidl)
204 travellog_entry *new, *cursor, *cursor2;
205 TRACE("%p (old count %d)\n", pidl, This->travellog_count);
207 /* Replace the old tail, if any, with the new entry */
208 if(This->travellog_cursor)
210 LIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, &This->travellog, travellog_entry, entry)
212 if(cursor == This->travellog_cursor)
213 break;
214 travellog_remove_entry(This, cursor);
218 /* Create and add the new entry */
219 new = heap_alloc(sizeof(*new));
220 new->pidl = ILClone(pidl);
221 list_add_tail(&This->travellog, &new->entry);
222 This->travellog_cursor = new;
223 This->travellog_count++;
225 /* Remove the first few entries if the size limit is reached. */
226 if(This->travellog_count > 200)
228 UINT i = 0;
229 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
231 if(i++ > 10)
232 break;
233 travellog_remove_entry(This, cursor);
238 static LPCITEMIDLIST travellog_go_back(ExplorerBrowserImpl *This)
240 travellog_entry *prev;
241 TRACE("%p, %p\n", This, This->travellog_cursor);
243 if(!This->travellog_cursor)
244 return NULL;
246 prev = LIST_ENTRY(list_prev(&This->travellog, &This->travellog_cursor->entry),
247 travellog_entry, entry);
248 if(!prev)
249 return NULL;
251 This->travellog_cursor = prev;
252 return prev->pidl;
255 static LPCITEMIDLIST travellog_go_forward(ExplorerBrowserImpl *This)
257 travellog_entry *next;
258 TRACE("%p, %p\n", This, This->travellog_cursor);
260 if(!This->travellog_cursor)
261 return NULL;
263 next = LIST_ENTRY(list_next(&This->travellog, &This->travellog_cursor->entry),
264 travellog_entry, entry);
265 if(!next)
266 return NULL;
268 This->travellog_cursor = next;
269 return next->pidl;
272 /**************************************************************************
273 * Helper functions
275 static void update_layout(ExplorerBrowserImpl *This)
277 RECT rc;
278 INT navpane_width_actual;
279 INT shellview_width_actual;
280 int np_min_width = MulDiv(NP_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
281 int sv_min_width = MulDiv(SV_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
282 TRACE("%p (navpane: %d, EBO_SHOWFRAMES: %d)\n",
283 This, This->navpane.show, This->eb_options & EBO_SHOWFRAMES);
285 GetClientRect(This->hwnd_main, &rc);
287 if((This->eb_options & EBO_SHOWFRAMES) && This->navpane.show)
288 navpane_width_actual = This->navpane.width;
289 else
290 navpane_width_actual = 0;
292 shellview_width_actual = rc.right - navpane_width_actual;
293 if(shellview_width_actual < sv_min_width && navpane_width_actual)
295 INT missing_width = sv_min_width - shellview_width_actual;
296 if(missing_width < (navpane_width_actual - np_min_width))
298 /* Shrink the navpane */
299 navpane_width_actual -= missing_width;
300 shellview_width_actual += missing_width;
302 else
304 /* Hide the navpane */
305 shellview_width_actual += navpane_width_actual;
306 navpane_width_actual = 0;
310 /**************************************************************
311 * Calculate rectangles for the panes. All rectangles contain
312 * the position of the panes relative to hwnd_main.
315 if(navpane_width_actual)
317 This->navpane.rc.left = This->navpane.rc.top = 0;
318 This->navpane.rc.right = navpane_width_actual;
319 This->navpane.rc.bottom = rc.bottom;
321 if(!This->navpane.hwnd_splitter)
322 initialize_navpane(This, This->hwnd_main, &This->navpane.rc);
324 else
325 ZeroMemory(&This->navpane.rc, sizeof(RECT));
327 This->sv_rc.left = navpane_width_actual;
328 This->sv_rc.top = 0;
329 This->sv_rc.right = This->sv_rc.left + shellview_width_actual;
330 This->sv_rc.bottom = rc.bottom;
333 static void size_panes(ExplorerBrowserImpl *This)
335 int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
336 MoveWindow(This->navpane.hwnd_splitter,
337 This->navpane.rc.right - splitter_width, This->navpane.rc.top,
338 splitter_width, This->navpane.rc.bottom - This->navpane.rc.top,
339 TRUE);
341 MoveWindow(This->hwnd_sv,
342 This->sv_rc.left, This->sv_rc.top,
343 This->sv_rc.right - This->sv_rc.left, This->sv_rc.bottom - This->sv_rc.top,
344 TRUE);
347 static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
349 IFolderView *pfv;
350 HRESULT hr;
352 if(!This->psv)
353 return E_FAIL;
355 hr = IShellView_QueryInterface(This->psv, &IID_IFolderView, (void*)&pfv);
356 if(SUCCEEDED(hr))
358 hr = IFolderView_SetCurrentViewMode(pfv, This->fs.ViewMode);
359 IFolderView_Release(pfv);
362 return hr;
365 static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi)
367 IShellBrowser *psb = &This->IShellBrowser_iface;
368 IShellFolder *psf;
369 IShellView *psv;
370 HWND hwnd_new;
371 HRESULT hr;
373 TRACE("%p, %p\n", This, psi);
375 hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFObject, &IID_IShellFolder, (void**)&psf);
376 if(SUCCEEDED(hr))
378 hr = IShellFolder_CreateViewObject(psf, This->hwnd_main, &IID_IShellView, (void**)&psv);
379 if(SUCCEEDED(hr))
381 if(This->hwnd_sv)
383 IShellView_DestroyViewWindow(This->psv);
384 This->hwnd_sv = NULL;
387 hr = IShellView_CreateViewWindow(psv, This->psv, &This->fs, psb, &This->sv_rc, &hwnd_new);
388 if(SUCCEEDED(hr))
390 /* Replace the old shellview */
391 if(This->psv) IShellView_Release(This->psv);
393 This->psv = psv;
394 This->hwnd_sv = hwnd_new;
395 events_ViewCreated(This, psv);
397 else
399 ERR("CreateViewWindow failed (0x%x)\n", hr);
400 IShellView_Release(psv);
403 else
404 ERR("CreateViewObject failed (0x%x)\n", hr);
406 IShellFolder_Release(psf);
408 else
409 ERR("SI::BindToHandler failed (0x%x)\n", hr);
411 return hr;
414 static void get_interfaces_from_site(ExplorerBrowserImpl *This)
416 IServiceProvider *psp;
417 HRESULT hr;
419 /* Calling this with This->punk_site set to NULL should properly
420 * release any previously fetched interfaces.
423 if(This->pcdb_site)
425 ICommDlgBrowser_Release(This->pcdb_site);
426 if(This->pcdb2_site) ICommDlgBrowser2_Release(This->pcdb2_site);
427 if(This->pcdb3_site) ICommDlgBrowser3_Release(This->pcdb3_site);
429 This->pcdb_site = NULL;
430 This->pcdb2_site = NULL;
431 This->pcdb3_site = NULL;
434 if(This->pepv_site)
436 IExplorerPaneVisibility_Release(This->pepv_site);
437 This->pepv_site = NULL;
440 if(!This->punk_site)
441 return;
443 hr = IUnknown_QueryInterface(This->punk_site, &IID_IServiceProvider, (void**)&psp);
444 if(FAILED(hr))
446 ERR("Failed to get IServiceProvider from site.\n");
447 return;
450 /* ICommDlgBrowser */
451 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser,
452 (void**)&This->pcdb_site);
453 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2,
454 (void**)&This->pcdb2_site);
455 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3,
456 (void**)&This->pcdb3_site);
458 /* IExplorerPaneVisibility */
459 IServiceProvider_QueryService(psp, &SID_ExplorerPaneVisibility, &IID_IExplorerPaneVisibility,
460 (void**)&This->pepv_site);
462 IServiceProvider_Release(psp);
465 /**************************************************************************
466 * General pane functionality.
468 static void update_panestate(ExplorerBrowserImpl *This)
470 EXPLORERPANESTATE eps = EPS_DONTCARE;
471 BOOL show_navpane;
472 TRACE("%p\n", This);
474 if(!This->pepv_site) return;
476 IExplorerPaneVisibility_GetPaneState(This->pepv_site, (REFEXPLORERPANE) &EP_NavPane, &eps);
477 if( !(eps & EPS_DEFAULT_OFF) )
478 show_navpane = TRUE;
479 else
480 show_navpane = FALSE;
482 if(This->navpane.show != show_navpane)
484 update_layout(This);
485 size_panes(This);
488 This->navpane.show = show_navpane;
491 static void splitter_draw(HWND hwnd, RECT *rc)
493 HDC hdc = GetDC(hwnd);
494 InvertRect(hdc, rc);
495 ReleaseDC(hwnd, hdc);
498 /**************************************************************************
499 * The Navigation Pane.
501 static LRESULT navpane_splitter_beginresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
503 int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
505 TRACE("\n");
507 SetCapture(hwnd);
509 This->splitter_rc = This->navpane.rc;
510 This->splitter_rc.left = This->splitter_rc.right - splitter_width;
512 splitter_draw(GetParent(hwnd), &This->splitter_rc);
514 return TRUE;
517 static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
519 int new_width, dx;
520 RECT rc;
521 int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
522 int np_min_width = MulDiv(NP_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
523 int sv_min_width = MulDiv(SV_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
525 if(GetCapture() != hwnd) return FALSE;
527 dx = (SHORT)LOWORD(lParam);
528 TRACE("%d.\n", dx);
530 rc = This->navpane.rc;
531 new_width = This->navpane.width + dx;
532 if(new_width > np_min_width && This->sv_rc.right - new_width > sv_min_width)
534 rc.right = new_width;
535 rc.left = rc.right - splitter_width;
536 splitter_draw(GetParent(hwnd), &This->splitter_rc);
537 splitter_draw(GetParent(hwnd), &rc);
538 This->splitter_rc = rc;
541 return TRUE;
544 static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
546 int new_width, dx;
547 int np_min_width = MulDiv(NP_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
548 int sv_min_width = MulDiv(SV_MIN_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
550 if(GetCapture() != hwnd) return FALSE;
552 dx = (SHORT)LOWORD(lParam);
553 TRACE("%d.\n", dx);
555 splitter_draw(GetParent(hwnd), &This->splitter_rc);
557 new_width = This->navpane.width + dx;
558 if(new_width < np_min_width)
559 new_width = np_min_width;
560 else if(This->sv_rc.right - new_width < sv_min_width)
561 new_width = This->sv_rc.right - sv_min_width;
563 This->navpane.width = new_width;
565 update_layout(This);
566 size_panes(This);
568 ReleaseCapture();
570 return TRUE;
573 static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
575 ExplorerBrowserImpl *This = crs->lpCreateParams;
576 INameSpaceTreeControl2 *pnstc2;
577 DWORD style;
578 HRESULT hr;
580 TRACE("%p\n", This);
581 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LPARAM)This);
582 This->navpane.hwnd_splitter = hwnd;
584 hr = CoCreateInstance(&CLSID_NamespaceTreeControl, NULL, CLSCTX_INPROC_SERVER,
585 &IID_INameSpaceTreeControl2, (void**)&pnstc2);
587 if(SUCCEEDED(hr))
589 style = NSTCS_HASEXPANDOS | NSTCS_ROOTHASEXPANDO | NSTCS_SHOWSELECTIONALWAYS;
590 hr = INameSpaceTreeControl2_Initialize(pnstc2, GetParent(hwnd), NULL, style);
591 if(SUCCEEDED(hr))
593 INameSpaceTreeControlEvents *pnstce;
594 IShellFolder *psfdesktop;
595 IShellItem *psi;
596 IOleWindow *pow;
597 LPITEMIDLIST pidl;
598 DWORD cookie, style2 = NSTCS2_DISPLAYPADDING;
600 hr = INameSpaceTreeControl2_SetControlStyle2(pnstc2, 0xFF, style2);
601 if(FAILED(hr))
602 ERR("SetControlStyle2 failed (0x%08x)\n", hr);
604 hr = INameSpaceTreeControl2_QueryInterface(pnstc2, &IID_IOleWindow, (void**)&pow);
605 if(SUCCEEDED(hr))
607 IOleWindow_GetWindow(pow, &This->navpane.hwnd_nstc);
608 IOleWindow_Release(pow);
610 else
611 ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr);
613 pnstce = &This->INameSpaceTreeControlEvents_iface;
614 hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie);
615 if(FAILED(hr))
616 ERR("TreeAdvise failed. (0x%08x).\n", hr);
619 * Add the default roots
622 /* TODO: This should be FOLDERID_Links */
623 hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
624 if(SUCCEEDED(hr))
626 hr = SHCreateShellItem(NULL, NULL, pidl, &psi);
627 if(SUCCEEDED(hr))
629 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_NONFOLDERS, NSTCRS_VISIBLE, NULL);
630 IShellItem_Release(psi);
632 ILFree(pidl);
635 SHGetDesktopFolder(&psfdesktop);
636 hr = SHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
637 IShellFolder_Release(psfdesktop);
638 if(SUCCEEDED(hr))
640 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_FOLDERS, NSTCRS_EXPANDED, NULL);
641 IShellItem_Release(psi);
644 /* TODO:
645 * We should advertise IID_INameSpaceTreeControl to the site of the
646 * host through its IProfferService interface, if any.
649 This->navpane.pnstc2 = pnstc2;
650 This->navpane.nstc_cookie = cookie;
652 return TRUE;
656 This->navpane.pnstc2 = NULL;
657 ERR("Failed (0x%08x)\n", hr);
659 return FALSE;
662 static LRESULT navpane_on_wm_size_move(ExplorerBrowserImpl *This)
664 UINT height, width;
665 int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
667 TRACE("%p\n", This);
669 width = This->navpane.rc.right - This->navpane.rc.left - splitter_width;
670 height = This->navpane.rc.bottom - This->navpane.rc.top;
672 MoveWindow(This->navpane.hwnd_nstc,
673 This->navpane.rc.left, This->navpane.rc.top,
674 width, height,
675 TRUE);
677 return FALSE;
680 static LRESULT navpane_on_wm_destroy(ExplorerBrowserImpl *This)
682 INameSpaceTreeControl2_TreeUnadvise(This->navpane.pnstc2, This->navpane.nstc_cookie);
683 INameSpaceTreeControl2_Release(This->navpane.pnstc2);
684 This->navpane.pnstc2 = NULL;
685 return TRUE;
688 static LRESULT CALLBACK navpane_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
690 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
692 switch(uMessage) {
693 case WM_CREATE: return navpane_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
694 case WM_MOVE: /* Fall through */
695 case WM_SIZE: return navpane_on_wm_size_move(This);
696 case WM_DESTROY: return navpane_on_wm_destroy(This);
697 case WM_LBUTTONDOWN: return navpane_splitter_beginresize(This, hWnd, lParam);
698 case WM_MOUSEMOVE: return navpane_splitter_resizing(This, hWnd, lParam);
699 case WM_LBUTTONUP: return navpane_splitter_endresize(This, hWnd, lParam);
700 default:
701 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
703 return 0;
706 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc)
708 WNDCLASSW wc;
709 HWND splitter;
710 int splitter_width = MulDiv(SPLITTER_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
711 static const WCHAR navpane_classname[] = {'e','b','_','n','a','v','p','a','n','e',0};
713 if( !GetClassInfoW(shell32_hInstance, navpane_classname, &wc) )
715 wc.style = CS_HREDRAW | CS_VREDRAW;
716 wc.lpfnWndProc = navpane_wndproc;
717 wc.cbClsExtra = 0;
718 wc.cbWndExtra = 0;
719 wc.hInstance = shell32_hInstance;
720 wc.hIcon = 0;
721 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_SIZEWE);
722 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
723 wc.lpszMenuName = NULL;
724 wc.lpszClassName = navpane_classname;
726 if (!RegisterClassW(&wc)) return;
729 splitter = CreateWindowExW(0, navpane_classname, NULL,
730 WS_CHILD | WS_TABSTOP | WS_VISIBLE,
731 rc->right - splitter_width, rc->top,
732 splitter_width, rc->bottom - rc->top,
733 hwnd_parent, 0, shell32_hInstance, This);
734 if(!splitter)
735 ERR("Failed to create navpane : %d.\n", GetLastError());
738 /**************************************************************************
739 * Main window related functions.
741 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
743 ExplorerBrowserImpl *This = crs->lpCreateParams;
744 TRACE("%p\n", This);
746 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
747 This->hwnd_main = hWnd;
749 return TRUE;
752 static LRESULT main_on_wm_size(ExplorerBrowserImpl *This)
754 update_layout(This);
755 size_panes(This);
757 return TRUE;
760 static LRESULT main_on_cwm_getishellbrowser(ExplorerBrowserImpl *This)
762 return (LRESULT)&This->IShellBrowser_iface;
765 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
767 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
769 switch(uMessage)
771 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
772 case WM_SIZE: return main_on_wm_size(This);
773 case CWM_GETISHELLBROWSER: return main_on_cwm_getishellbrowser(This);
774 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
777 return 0;
780 /**************************************************************************
781 * IExplorerBrowser Implementation
784 static inline ExplorerBrowserImpl *impl_from_IExplorerBrowser(IExplorerBrowser *iface)
786 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IExplorerBrowser_iface);
789 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
790 REFIID riid, void **ppvObject)
792 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
793 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
795 *ppvObject = NULL;
796 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
797 IsEqualIID(riid, &IID_IUnknown))
799 *ppvObject = &This->IExplorerBrowser_iface;
801 else if(IsEqualIID(riid, &IID_IShellBrowser) ||
802 IsEqualIID(riid, &IID_IOleWindow))
804 *ppvObject = &This->IShellBrowser_iface;
806 else if(IsEqualIID(riid, &IID_ICommDlgBrowser) ||
807 IsEqualIID(riid, &IID_ICommDlgBrowser2) ||
808 IsEqualIID(riid, &IID_ICommDlgBrowser3))
810 *ppvObject = &This->ICommDlgBrowser3_iface;
812 else if(IsEqualIID(riid, &IID_IObjectWithSite))
814 *ppvObject = &This->IObjectWithSite_iface;
816 else if(IsEqualIID(riid, &IID_IInputObject))
818 *ppvObject = &This->IInputObject_iface;
821 if(*ppvObject)
823 IUnknown_AddRef((IUnknown*)*ppvObject);
824 return S_OK;
827 return E_NOINTERFACE;
830 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
832 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
833 LONG ref = InterlockedIncrement(&This->ref);
834 TRACE("%p - ref %d\n", This, ref);
836 return ref;
839 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
841 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
842 LONG ref = InterlockedDecrement(&This->ref);
843 TRACE("%p - ref %d\n", This, ref);
845 if(!ref)
847 TRACE("Freeing.\n");
849 if(!This->destroyed)
850 IExplorerBrowser_Destroy(iface);
852 IObjectWithSite_SetSite(&This->IObjectWithSite_iface, NULL);
854 heap_free(This);
857 return ref;
860 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
861 HWND hwndParent, const RECT *prc,
862 const FOLDERSETTINGS *pfs)
864 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
865 WNDCLASSW wc;
866 LONG style;
867 HDC parent_dc;
868 static const WCHAR EB_CLASS_NAME[] =
869 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
871 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
873 if(This->hwnd_main)
874 return E_UNEXPECTED;
876 if(!hwndParent)
877 return E_INVALIDARG;
879 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
881 wc.style = CS_HREDRAW | CS_VREDRAW;
882 wc.lpfnWndProc = main_wndproc;
883 wc.cbClsExtra = 0;
884 wc.cbWndExtra = 0;
885 wc.hInstance = shell32_hInstance;
886 wc.hIcon = 0;
887 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
888 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
889 wc.lpszMenuName = NULL;
890 wc.lpszClassName = EB_CLASS_NAME;
892 if (!RegisterClassW(&wc)) return E_FAIL;
895 parent_dc = GetDC(hwndParent);
896 This->dpix = GetDeviceCaps(parent_dc, LOGPIXELSX);
897 ReleaseDC(hwndParent, parent_dc);
899 This->navpane.width = MulDiv(NP_DEFAULT_WIDTH, This->dpix, USER_DEFAULT_SCREEN_DPI);
901 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
902 if (!(This->eb_options & EBO_NOBORDER))
903 style |= WS_BORDER;
904 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
905 prc->left, prc->top,
906 prc->right - prc->left, prc->bottom - prc->top,
907 hwndParent, 0, shell32_hInstance, This);
909 if(!This->hwnd_main)
911 ERR("Failed to create the window.\n");
912 return E_FAIL;
915 This->fs.ViewMode = pfs ? pfs->ViewMode : FVM_DETAILS;
916 This->fs.fFlags = pfs ? (pfs->fFlags | FWF_NOCLIENTEDGE) : FWF_NOCLIENTEDGE;
918 return S_OK;
921 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
923 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
924 TRACE("%p\n", This);
926 if(This->psv)
928 IShellView_DestroyViewWindow(This->psv);
929 IShellView_Release(This->psv);
930 This->psv = NULL;
931 This->hwnd_sv = NULL;
934 events_unadvise_all(This);
935 travellog_remove_all_entries(This);
937 ILFree(This->current_pidl);
938 This->current_pidl = NULL;
940 DestroyWindow(This->hwnd_main);
941 This->destroyed = TRUE;
943 return S_OK;
946 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
947 HDWP *phdwp, RECT rcBrowser)
949 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
950 TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
952 if(phdwp && *phdwp)
954 *phdwp = DeferWindowPos(*phdwp, This->hwnd_main, NULL, rcBrowser.left, rcBrowser.top,
955 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top,
956 SWP_NOZORDER | SWP_NOACTIVATE);
957 if(!*phdwp)
958 return E_FAIL;
960 else
962 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
963 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
966 return S_OK;
969 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
970 LPCWSTR pszPropertyBag)
972 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
973 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
975 if(!pszPropertyBag)
976 return E_INVALIDARG;
978 /* FIXME: This method is currently useless as we don't save any
979 * settings anywhere, but at least one application breaks if we
980 * return E_NOTIMPL.
983 return S_OK;
986 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
987 LPCWSTR pszEmptyText)
989 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
990 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
992 return E_NOTIMPL;
995 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
996 const FOLDERSETTINGS *pfs)
998 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
999 TRACE("%p (%p)\n", This, pfs);
1001 if(!pfs)
1002 return E_INVALIDARG;
1004 This->fs.ViewMode = pfs->ViewMode;
1005 This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
1007 /* Change the settings of the current view, if any. */
1008 return change_viewmode(This, This->fs.ViewMode);
1011 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
1012 IExplorerBrowserEvents *psbe,
1013 DWORD *pdwCookie)
1015 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1016 event_client *client;
1017 TRACE("%p (%p, %p)\n", This, psbe, pdwCookie);
1019 client = heap_alloc(sizeof(*client));
1020 client->pebe = psbe;
1021 client->cookie = ++This->events_next_cookie;
1023 IExplorerBrowserEvents_AddRef(psbe);
1024 *pdwCookie = client->cookie;
1026 list_add_tail(&This->event_clients, &client->entry);
1028 return S_OK;
1031 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
1032 DWORD dwCookie)
1034 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1035 event_client *client;
1036 TRACE("%p (0x%x)\n", This, dwCookie);
1038 LIST_FOR_EACH_ENTRY(client, &This->event_clients, event_client, entry)
1040 if(client->cookie == dwCookie)
1042 list_remove(&client->entry);
1043 IExplorerBrowserEvents_Release(client->pebe);
1044 heap_free(client);
1045 return S_OK;
1049 return E_INVALIDARG;
1052 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
1053 EXPLORER_BROWSER_OPTIONS dwFlag)
1055 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1056 static const EXPLORER_BROWSER_OPTIONS unsupported_options =
1057 EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW | EBO_NOPERSISTVIEWSTATE;
1059 TRACE("%p (0x%x)\n", This, dwFlag);
1061 if(dwFlag & unsupported_options)
1062 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag);
1064 This->eb_options = dwFlag;
1066 return S_OK;
1069 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
1070 EXPLORER_BROWSER_OPTIONS *pdwFlag)
1072 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1073 TRACE("%p (%p)\n", This, pdwFlag);
1075 *pdwFlag = This->eb_options;
1077 return S_OK;
1080 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
1081 PCUIDLIST_RELATIVE pidl,
1082 UINT uFlags)
1084 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1085 LPITEMIDLIST absolute_pidl = NULL;
1086 HRESULT hr;
1087 static const UINT unsupported_browse_flags =
1088 SBSP_NEWBROWSER | EBF_SELECTFROMDATAOBJECT | EBF_NODROPTARGET;
1089 TRACE("%p (%p, 0x%x)\n", This, pidl, uFlags);
1091 if(!This->hwnd_main)
1092 return E_FAIL;
1094 if(This->destroyed)
1095 return HRESULT_FROM_WIN32(ERROR_BUSY);
1097 if(This->current_pidl && (This->eb_options & EBO_NAVIGATEONCE))
1098 return E_FAIL;
1100 if(uFlags & SBSP_EXPLOREMODE)
1101 return E_INVALIDARG;
1103 if(uFlags & unsupported_browse_flags)
1104 FIXME("Argument 0x%x contains unsupported flags.\n", uFlags);
1106 if(uFlags & SBSP_NAVIGATEBACK)
1108 TRACE("SBSP_NAVIGATEBACK\n");
1109 absolute_pidl = ILClone(travellog_go_back(This));
1110 if(!absolute_pidl && !This->current_pidl)
1111 return E_FAIL;
1112 else if(!absolute_pidl)
1113 return S_OK;
1116 else if(uFlags & SBSP_NAVIGATEFORWARD)
1118 TRACE("SBSP_NAVIGATEFORWARD\n");
1119 absolute_pidl = ILClone(travellog_go_forward(This));
1120 if(!absolute_pidl && !This->current_pidl)
1121 return E_FAIL;
1122 else if(!absolute_pidl)
1123 return S_OK;
1126 else if(uFlags & SBSP_PARENT)
1128 if(This->current_pidl)
1130 if(_ILIsPidlSimple(This->current_pidl))
1132 absolute_pidl = _ILCreateDesktop();
1134 else
1136 absolute_pidl = ILClone(This->current_pidl);
1137 ILRemoveLastID(absolute_pidl);
1140 if(!absolute_pidl)
1142 ERR("Failed to get parent pidl.\n");
1143 return E_FAIL;
1147 else if(uFlags & SBSP_RELATIVE)
1149 /* SBSP_RELATIVE has precedence over SBSP_ABSOLUTE */
1150 TRACE("SBSP_RELATIVE\n");
1151 if(This->current_pidl)
1153 absolute_pidl = ILCombine(This->current_pidl, pidl);
1155 if(!absolute_pidl)
1157 ERR("Failed to get absolute pidl.\n");
1158 return E_FAIL;
1161 else
1163 TRACE("SBSP_ABSOLUTE\n");
1164 absolute_pidl = ILClone(pidl);
1165 if(!absolute_pidl && !This->current_pidl)
1166 return E_INVALIDARG;
1167 else if(!absolute_pidl)
1168 return S_OK;
1171 /* TODO: Asynchronous browsing. Return S_OK here and finish in
1172 * another thread. */
1174 hr = events_NavigationPending(This, absolute_pidl);
1175 if(FAILED(hr))
1177 TRACE("Browsing aborted.\n");
1178 ILFree(absolute_pidl);
1179 return E_FAIL;
1182 get_interfaces_from_site(This);
1183 update_panestate(This);
1185 /* Only browse if the new pidl differs from the old */
1186 if(!ILIsEqual(This->current_pidl, absolute_pidl))
1188 IShellItem *psi;
1189 hr = SHCreateItemFromIDList(absolute_pidl, &IID_IShellItem, (void**)&psi);
1190 if(SUCCEEDED(hr))
1192 hr = create_new_shellview(This, psi);
1193 if(FAILED(hr))
1195 events_NavigationFailed(This, absolute_pidl);
1196 ILFree(absolute_pidl);
1197 IShellItem_Release(psi);
1198 return E_FAIL;
1201 /* Add to travellog */
1202 if( !(This->eb_options & EBO_NOTRAVELLOG) &&
1203 !(uFlags & (SBSP_NAVIGATEFORWARD|SBSP_NAVIGATEBACK)) )
1205 travellog_add_entry(This, absolute_pidl);
1208 IShellItem_Release(psi);
1212 events_NavigationComplete(This, absolute_pidl);
1213 ILFree(This->current_pidl);
1214 This->current_pidl = absolute_pidl;
1216 /* Expand the NameSpaceTree to the current location. */
1217 if(This->navpane.show && This->navpane.pnstc2)
1219 IShellItem *psi;
1220 hr = SHCreateItemFromIDList(This->current_pidl, &IID_IShellItem, (void**)&psi);
1221 if(SUCCEEDED(hr))
1223 INameSpaceTreeControl2_EnsureItemVisible(This->navpane.pnstc2, psi);
1224 IShellItem_Release(psi);
1228 return S_OK;
1231 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
1232 IUnknown *punk, UINT uFlags)
1234 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1235 LPITEMIDLIST pidl;
1236 HRESULT hr;
1237 TRACE("%p (%p, 0x%x)\n", This, punk, uFlags);
1239 if(!punk)
1240 return IExplorerBrowser_BrowseToIDList(iface, NULL, uFlags);
1242 hr = SHGetIDListFromObject(punk, &pidl);
1243 if(SUCCEEDED(hr))
1245 hr = IExplorerBrowser_BrowseToIDList(iface, pidl, uFlags);
1246 ILFree(pidl);
1249 return hr;
1252 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
1253 IUnknown *punk,
1254 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
1256 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1257 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
1259 return E_NOTIMPL;
1262 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
1264 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1265 FIXME("stub, %p\n", This);
1267 return E_NOTIMPL;
1270 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
1271 REFIID riid, void **ppv)
1273 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1274 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
1276 if(!This->psv)
1277 return E_FAIL;
1279 return IShellView_QueryInterface(This->psv, riid, ppv);
1282 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
1284 IExplorerBrowser_fnQueryInterface,
1285 IExplorerBrowser_fnAddRef,
1286 IExplorerBrowser_fnRelease,
1287 IExplorerBrowser_fnInitialize,
1288 IExplorerBrowser_fnDestroy,
1289 IExplorerBrowser_fnSetRect,
1290 IExplorerBrowser_fnSetPropertyBag,
1291 IExplorerBrowser_fnSetEmptyText,
1292 IExplorerBrowser_fnSetFolderSettings,
1293 IExplorerBrowser_fnAdvise,
1294 IExplorerBrowser_fnUnadvise,
1295 IExplorerBrowser_fnSetOptions,
1296 IExplorerBrowser_fnGetOptions,
1297 IExplorerBrowser_fnBrowseToIDList,
1298 IExplorerBrowser_fnBrowseToObject,
1299 IExplorerBrowser_fnFillFromObject,
1300 IExplorerBrowser_fnRemoveAll,
1301 IExplorerBrowser_fnGetCurrentView
1304 /**************************************************************************
1305 * IShellBrowser Implementation
1308 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
1310 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IShellBrowser_iface);
1313 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
1314 REFIID riid, void **ppvObject)
1316 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1317 TRACE("%p\n", This);
1318 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1321 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
1323 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1324 TRACE("%p\n", This);
1325 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1328 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
1330 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1331 TRACE("%p\n", This);
1332 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1335 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
1337 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1338 TRACE("%p (%p)\n", This, phwnd);
1340 if(!This->hwnd_main)
1341 return E_FAIL;
1343 *phwnd = This->hwnd_main;
1344 return S_OK;
1347 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
1348 BOOL fEnterMode)
1350 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1351 FIXME("stub, %p (%d)\n", This, fEnterMode);
1353 return E_NOTIMPL;
1356 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
1357 HMENU hmenuShared,
1358 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1360 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1361 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
1363 /* Not implemented. */
1364 return E_NOTIMPL;
1367 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
1368 HMENU hmenuShared,
1369 HOLEMENU holemenuReserved,
1370 HWND hwndActiveObject)
1372 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1373 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
1375 /* Not implemented. */
1376 return E_NOTIMPL;
1379 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
1380 HMENU hmenuShared)
1382 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1383 TRACE("%p (%p)\n", This, hmenuShared);
1385 /* Not implemented. */
1386 return E_NOTIMPL;
1389 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
1390 LPCOLESTR pszStatusText)
1392 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1393 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
1395 return E_NOTIMPL;
1398 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
1399 BOOL fEnable)
1401 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1402 FIXME("stub, %p (%d)\n", This, fEnable);
1404 return E_NOTIMPL;
1407 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
1408 MSG *pmsg, WORD wID)
1410 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1411 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
1413 return E_NOTIMPL;
1416 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
1417 LPCITEMIDLIST pidl, UINT wFlags)
1419 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1420 TRACE("%p (%p, %x)\n", This, pidl, wFlags);
1422 return IExplorerBrowser_BrowseToIDList(&This->IExplorerBrowser_iface, pidl, wFlags);
1425 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
1426 DWORD grfMode,
1427 IStream **ppStrm)
1429 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1430 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
1432 *ppStrm = NULL;
1433 return E_FAIL;
1436 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
1437 UINT id, HWND *phwnd)
1439 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1440 TRACE("(%p)->(%d, %p)\n", This, id, phwnd);
1441 if (phwnd) *phwnd = NULL;
1442 return E_NOTIMPL;
1445 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
1446 UINT id, UINT uMsg,
1447 WPARAM wParam, LPARAM lParam,
1448 LRESULT *pret)
1450 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1451 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
1453 return E_NOTIMPL;
1456 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
1457 IShellView **ppshv)
1459 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1460 TRACE("%p (%p)\n", This, ppshv);
1462 if(!This->psv)
1463 return E_FAIL;
1465 *ppshv = This->psv;
1466 IShellView_AddRef(This->psv);
1468 return S_OK;
1471 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
1472 IShellView *pshv)
1474 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1475 FIXME("stub, %p (%p)\n", This, pshv);
1477 return E_NOTIMPL;
1480 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
1481 LPTBBUTTONSB lpButtons,
1482 UINT nButtons, UINT uFlags)
1484 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1485 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
1487 return E_NOTIMPL;
1490 static const IShellBrowserVtbl vt_IShellBrowser = {
1491 IShellBrowser_fnQueryInterface,
1492 IShellBrowser_fnAddRef,
1493 IShellBrowser_fnRelease,
1494 IShellBrowser_fnGetWindow,
1495 IShellBrowser_fnContextSensitiveHelp,
1496 IShellBrowser_fnInsertMenusSB,
1497 IShellBrowser_fnSetMenuSB,
1498 IShellBrowser_fnRemoveMenusSB,
1499 IShellBrowser_fnSetStatusTextSB,
1500 IShellBrowser_fnEnableModelessSB,
1501 IShellBrowser_fnTranslateAcceleratorSB,
1502 IShellBrowser_fnBrowseObject,
1503 IShellBrowser_fnGetViewStateStream,
1504 IShellBrowser_fnGetControlWindow,
1505 IShellBrowser_fnSendControlMsg,
1506 IShellBrowser_fnQueryActiveShellView,
1507 IShellBrowser_fnOnViewWindowActive,
1508 IShellBrowser_fnSetToolbarItems
1511 /**************************************************************************
1512 * ICommDlgBrowser3 Implementation
1515 static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
1517 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, ICommDlgBrowser3_iface);
1520 static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface,
1521 REFIID riid,
1522 void **ppvObject)
1524 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1525 TRACE("%p\n", This);
1526 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1529 static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
1531 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1532 TRACE("%p\n", This);
1533 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1536 static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
1538 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1539 TRACE("%p\n", This);
1540 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1543 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *iface,
1544 IShellView *shv)
1546 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1547 IDataObject *pdo;
1548 HRESULT hr;
1549 HRESULT ret = S_FALSE;
1551 TRACE("%p (%p)\n", This, shv);
1553 hr = IShellView_GetItemObject(shv, SVGIO_SELECTION, &IID_IDataObject, (void**)&pdo);
1554 if(SUCCEEDED(hr))
1556 FORMATETC fmt;
1557 STGMEDIUM medium;
1559 fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
1560 fmt.ptd = NULL;
1561 fmt.dwAspect = DVASPECT_CONTENT;
1562 fmt.lindex = -1;
1563 fmt.tymed = TYMED_HGLOBAL;
1565 hr = IDataObject_GetData(pdo, &fmt ,&medium);
1566 IDataObject_Release(pdo);
1567 if(SUCCEEDED(hr))
1569 LPIDA pida = GlobalLock(medium.u.hGlobal);
1570 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
1572 /* Handle folders by browsing to them. */
1573 if(_ILIsFolder(pidl_child) || _ILIsDrive(pidl_child) || _ILIsSpecialFolder(pidl_child))
1575 IExplorerBrowser_BrowseToIDList(&This->IExplorerBrowser_iface, pidl_child, SBSP_RELATIVE);
1576 ret = S_OK;
1578 GlobalUnlock(medium.u.hGlobal);
1579 GlobalFree(medium.u.hGlobal);
1581 else
1582 ERR("Failed to get data from IDataObject.\n");
1583 } else
1584 ERR("Failed to get IDataObject.\n");
1586 /* If we didn't handle the default command, check if we have a
1587 * client that does */
1588 if(ret == S_FALSE && This->pcdb_site)
1589 return ICommDlgBrowser_OnDefaultCommand(This->pcdb_site, shv);
1591 return ret;
1593 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface,
1594 IShellView *shv, ULONG uChange)
1596 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1597 TRACE("%p (%p, %d)\n", This, shv, uChange);
1599 if(This->pcdb_site)
1600 return ICommDlgBrowser_OnStateChange(This->pcdb_site, shv, uChange);
1602 return E_NOTIMPL;
1604 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
1605 IShellView *pshv, LPCITEMIDLIST pidl)
1607 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1608 TRACE("%p (%p, %p)\n", This, pshv, pidl);
1610 if(This->pcdb_site)
1611 return ICommDlgBrowser_IncludeObject(This->pcdb_site, pshv, pidl);
1613 return S_OK;
1616 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
1617 IShellView *pshv,
1618 DWORD dwNotifyType)
1620 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1621 TRACE("%p (%p, 0x%x)\n", This, pshv, dwNotifyType);
1623 if(This->pcdb2_site)
1624 return ICommDlgBrowser2_Notify(This->pcdb2_site, pshv, dwNotifyType);
1626 return S_OK;
1629 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(ICommDlgBrowser3 *iface,
1630 IShellView *pshv,
1631 LPWSTR pszText, int cchMax)
1633 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1634 TRACE("%p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
1636 if(This->pcdb2_site)
1637 return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb2_site, pshv, pszText, cchMax);
1639 return S_OK;
1642 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(ICommDlgBrowser3 *iface,
1643 DWORD *pdwFlags)
1645 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1646 TRACE("%p (%p)\n", This, pdwFlags);
1648 if(This->pcdb2_site)
1649 return ICommDlgBrowser2_GetViewFlags(This->pcdb2_site, pdwFlags);
1651 return S_OK;
1654 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(ICommDlgBrowser3 *iface,
1655 IShellView *pshv, int iColumn)
1657 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1658 TRACE("%p (%p, %d)\n", This, pshv, iColumn);
1660 if(This->pcdb3_site)
1661 return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
1663 return S_OK;
1666 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(ICommDlgBrowser3 *iface,
1667 LPWSTR pszFileSpec,
1668 int cchFileSpec)
1670 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1671 TRACE("%p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
1673 if(This->pcdb3_site)
1674 return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
1676 return S_OK;
1679 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreViewCreated(ICommDlgBrowser3 *iface,
1680 IShellView *pshv)
1682 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1683 TRACE("%p (%p)\n", This, pshv);
1685 if(This->pcdb3_site)
1686 return ICommDlgBrowser3_OnPreViewCreated(This->pcdb3_site, pshv);
1688 return S_OK;
1691 static const ICommDlgBrowser3Vtbl vt_ICommDlgBrowser3 = {
1692 ICommDlgBrowser3_fnQueryInterface,
1693 ICommDlgBrowser3_fnAddRef,
1694 ICommDlgBrowser3_fnRelease,
1695 ICommDlgBrowser3_fnOnDefaultCommand,
1696 ICommDlgBrowser3_fnOnStateChange,
1697 ICommDlgBrowser3_fnIncludeObject,
1698 ICommDlgBrowser3_fnNotify,
1699 ICommDlgBrowser3_fnGetDefaultMenuText,
1700 ICommDlgBrowser3_fnGetViewFlags,
1701 ICommDlgBrowser3_fnOnColumnClicked,
1702 ICommDlgBrowser3_fnGetCurrentFilter,
1703 ICommDlgBrowser3_fnOnPreViewCreated
1706 /**************************************************************************
1707 * IObjectWithSite Implementation
1710 static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
1712 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IObjectWithSite_iface);
1715 static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface,
1716 REFIID riid, void **ppvObject)
1718 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1719 TRACE("%p\n", This);
1720 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
1723 static ULONG WINAPI IObjectWithSite_fnAddRef(IObjectWithSite *iface)
1725 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1726 TRACE("%p\n", This);
1727 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1730 static ULONG WINAPI IObjectWithSite_fnRelease(IObjectWithSite *iface)
1732 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1733 TRACE("%p\n", This);
1734 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1737 static HRESULT WINAPI IObjectWithSite_fnSetSite(IObjectWithSite *iface, IUnknown *punk_site)
1739 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1740 TRACE("%p (%p)\n", This, punk_site);
1742 if(This->punk_site)
1744 IUnknown_Release(This->punk_site);
1745 This->punk_site = NULL;
1746 get_interfaces_from_site(This);
1749 This->punk_site = punk_site;
1751 if(This->punk_site)
1752 IUnknown_AddRef(This->punk_site);
1754 return S_OK;
1757 static HRESULT WINAPI IObjectWithSite_fnGetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite)
1759 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1760 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvSite);
1762 if(!This->punk_site)
1763 return E_FAIL;
1765 return IUnknown_QueryInterface(This->punk_site, riid, ppvSite);
1768 static const IObjectWithSiteVtbl vt_IObjectWithSite = {
1769 IObjectWithSite_fnQueryInterface,
1770 IObjectWithSite_fnAddRef,
1771 IObjectWithSite_fnRelease,
1772 IObjectWithSite_fnSetSite,
1773 IObjectWithSite_fnGetSite
1776 /**************************************************************************
1777 * INameSpaceTreeControlEvents Implementation
1779 static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
1781 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, INameSpaceTreeControlEvents_iface);
1784 static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface,
1785 REFIID riid, void **ppvObject)
1787 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1788 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
1790 *ppvObject = NULL;
1791 if(IsEqualIID(riid, &IID_INameSpaceTreeControlEvents) ||
1792 IsEqualIID(riid, &IID_IUnknown))
1794 *ppvObject = iface;
1797 if(*ppvObject)
1799 IUnknown_AddRef((IUnknown*)*ppvObject);
1800 return S_OK;
1803 return E_NOINTERFACE;
1806 static ULONG WINAPI NSTCEvents_fnAddRef(INameSpaceTreeControlEvents *iface)
1808 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1809 TRACE("%p\n", This);
1810 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
1813 static ULONG WINAPI NSTCEvents_fnRelease(INameSpaceTreeControlEvents *iface)
1815 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1816 TRACE("%p\n", This);
1817 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
1820 static HRESULT WINAPI NSTCEvents_fnOnItemClick(INameSpaceTreeControlEvents *iface,
1821 IShellItem *psi,
1822 NSTCEHITTEST nstceHitTest,
1823 NSTCECLICKTYPE nstceClickType)
1825 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1826 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstceHitTest, nstceClickType);
1827 return S_OK;
1830 static HRESULT WINAPI NSTCEvents_fnOnPropertyItemCommit(INameSpaceTreeControlEvents *iface,
1831 IShellItem *psi)
1833 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1834 TRACE("%p (%p)\n", This, psi);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanging(INameSpaceTreeControlEvents *iface,
1839 IShellItem *psi,
1840 NSTCITEMSTATE nstcisMask,
1841 NSTCITEMSTATE nstcisState)
1843 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1844 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1845 return E_NOTIMPL;
1848 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanged(INameSpaceTreeControlEvents *iface,
1849 IShellItem *psi,
1850 NSTCITEMSTATE nstcisMask,
1851 NSTCITEMSTATE nstcisState)
1853 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1854 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1855 return E_NOTIMPL;
1858 static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(INameSpaceTreeControlEvents *iface,
1859 IShellItemArray *psiaSelection)
1861 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1862 IShellItem *psi;
1863 HRESULT hr;
1864 TRACE("%p (%p)\n", This, psiaSelection);
1866 hr = IShellItemArray_GetItemAt(psiaSelection, 0, &psi);
1867 if(SUCCEEDED(hr))
1869 hr = IExplorerBrowser_BrowseToObject(&This->IExplorerBrowser_iface,
1870 (IUnknown*)psi, SBSP_DEFBROWSER);
1871 IShellItem_Release(psi);
1874 return hr;
1877 static HRESULT WINAPI NSTCEvents_fnOnKeyboardInput(INameSpaceTreeControlEvents *iface,
1878 UINT uMsg, WPARAM wParam, LPARAM lParam)
1880 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1881 TRACE("%p (%d, 0x%lx, 0x%lx)\n", This, uMsg, wParam, lParam);
1882 return S_OK;
1885 static HRESULT WINAPI NSTCEvents_fnOnBeforeExpand(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_fnOnAfterExpand(INameSpaceTreeControlEvents *iface,
1894 IShellItem *psi)
1896 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1897 TRACE("%p (%p)\n", This, psi);
1898 return E_NOTIMPL;
1901 static HRESULT WINAPI NSTCEvents_fnOnBeginLabelEdit(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_fnOnEndLabelEdit(INameSpaceTreeControlEvents *iface,
1910 IShellItem *psi)
1912 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1913 TRACE("%p (%p)\n", This, psi);
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI NSTCEvents_fnOnGetToolTip(INameSpaceTreeControlEvents *iface,
1918 IShellItem *psi, LPWSTR pszTip, int cchTip)
1920 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1921 TRACE("%p (%p, %p, %d)\n", This, psi, pszTip, cchTip);
1922 return E_NOTIMPL;
1925 static HRESULT WINAPI NSTCEvents_fnOnBeforeItemDelete(INameSpaceTreeControlEvents *iface,
1926 IShellItem *psi)
1928 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1929 TRACE("%p (%p)\n", This, psi);
1930 return E_NOTIMPL;
1933 static HRESULT WINAPI NSTCEvents_fnOnItemAdded(INameSpaceTreeControlEvents *iface,
1934 IShellItem *psi, BOOL fIsRoot)
1936 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1937 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1938 return E_NOTIMPL;
1941 static HRESULT WINAPI NSTCEvents_fnOnItemDeleted(INameSpaceTreeControlEvents *iface,
1942 IShellItem *psi, BOOL fIsRoot)
1944 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1945 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1946 return E_NOTIMPL;
1949 static HRESULT WINAPI NSTCEvents_fnOnBeforeContextMenu(INameSpaceTreeControlEvents *iface,
1950 IShellItem *psi, REFIID riid, void **ppv)
1952 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1953 TRACE("%p (%p, %s, %p)\n", This, psi, shdebugstr_guid(riid), ppv);
1954 return E_NOTIMPL;
1957 static HRESULT WINAPI NSTCEvents_fnOnAfterContextMenu(INameSpaceTreeControlEvents *iface,
1958 IShellItem *psi, IContextMenu *pcmIn,
1959 REFIID riid, void **ppv)
1961 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1962 TRACE("%p (%p, %p, %s, %p)\n", This, psi, pcmIn, shdebugstr_guid(riid), ppv);
1963 return E_NOTIMPL;
1966 static HRESULT WINAPI NSTCEvents_fnOnBeforeStateImageChange(INameSpaceTreeControlEvents *iface,
1967 IShellItem *psi)
1969 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1970 TRACE("%p (%p)\n", This, psi);
1971 return E_NOTIMPL;
1974 static HRESULT WINAPI NSTCEvents_fnOnGetDefaultIconIndex(INameSpaceTreeControlEvents* iface,
1975 IShellItem *psi,
1976 int *piDefaultIcon, int *piOpenIcon)
1978 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1979 TRACE("%p (%p, %p, %p)\n", This, psi, piDefaultIcon, piOpenIcon);
1980 return E_NOTIMPL;
1984 static const INameSpaceTreeControlEventsVtbl vt_INameSpaceTreeControlEvents = {
1985 NSTCEvents_fnQueryInterface,
1986 NSTCEvents_fnAddRef,
1987 NSTCEvents_fnRelease,
1988 NSTCEvents_fnOnItemClick,
1989 NSTCEvents_fnOnPropertyItemCommit,
1990 NSTCEvents_fnOnItemStateChanging,
1991 NSTCEvents_fnOnItemStateChanged,
1992 NSTCEvents_fnOnSelectionChanged,
1993 NSTCEvents_fnOnKeyboardInput,
1994 NSTCEvents_fnOnBeforeExpand,
1995 NSTCEvents_fnOnAfterExpand,
1996 NSTCEvents_fnOnBeginLabelEdit,
1997 NSTCEvents_fnOnEndLabelEdit,
1998 NSTCEvents_fnOnGetToolTip,
1999 NSTCEvents_fnOnBeforeItemDelete,
2000 NSTCEvents_fnOnItemAdded,
2001 NSTCEvents_fnOnItemDeleted,
2002 NSTCEvents_fnOnBeforeContextMenu,
2003 NSTCEvents_fnOnAfterContextMenu,
2004 NSTCEvents_fnOnBeforeStateImageChange,
2005 NSTCEvents_fnOnGetDefaultIconIndex
2008 /**************************************************************************
2009 * IInputObject Implementation
2012 static inline ExplorerBrowserImpl *impl_from_IInputObject(IInputObject *iface)
2014 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IInputObject_iface);
2017 static HRESULT WINAPI IInputObject_fnQueryInterface(IInputObject *iface,
2018 REFIID riid, void **ppvObject)
2020 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2021 TRACE("%p\n", This);
2022 return IExplorerBrowser_QueryInterface(&This->IExplorerBrowser_iface, riid, ppvObject);
2025 static ULONG WINAPI IInputObject_fnAddRef(IInputObject *iface)
2027 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2028 TRACE("%p\n", This);
2029 return IExplorerBrowser_AddRef(&This->IExplorerBrowser_iface);
2032 static ULONG WINAPI IInputObject_fnRelease(IInputObject *iface)
2034 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2035 TRACE("%p\n", This);
2036 return IExplorerBrowser_Release(&This->IExplorerBrowser_iface);
2039 static HRESULT WINAPI IInputObject_fnUIActivateIO(IInputObject *iface, BOOL fActivate, MSG *pMsg)
2041 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2042 FIXME("stub, %p (%d, %p)\n", This, fActivate, pMsg);
2043 return E_NOTIMPL;
2046 static HRESULT WINAPI IInputObject_fnHasFocusIO(IInputObject *iface)
2048 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2049 FIXME("stub, %p\n", This);
2050 return E_NOTIMPL;
2053 static HRESULT WINAPI IInputObject_fnTranslateAcceleratorIO(IInputObject *iface, MSG *pMsg)
2055 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2056 FIXME("stub, %p (%p)\n", This, pMsg);
2057 return E_NOTIMPL;
2060 static IInputObjectVtbl vt_IInputObject = {
2061 IInputObject_fnQueryInterface,
2062 IInputObject_fnAddRef,
2063 IInputObject_fnRelease,
2064 IInputObject_fnUIActivateIO,
2065 IInputObject_fnHasFocusIO,
2066 IInputObject_fnTranslateAcceleratorIO
2069 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
2071 ExplorerBrowserImpl *eb;
2072 HRESULT ret;
2074 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
2076 if(!ppv)
2077 return E_POINTER;
2078 if(pUnkOuter)
2079 return CLASS_E_NOAGGREGATION;
2081 eb = heap_alloc_zero(sizeof(*eb));
2082 eb->ref = 1;
2083 eb->IExplorerBrowser_iface.lpVtbl = &vt_IExplorerBrowser;
2084 eb->IShellBrowser_iface.lpVtbl = &vt_IShellBrowser;
2085 eb->ICommDlgBrowser3_iface.lpVtbl = &vt_ICommDlgBrowser3;
2086 eb->IObjectWithSite_iface.lpVtbl = &vt_IObjectWithSite;
2087 eb->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_INameSpaceTreeControlEvents;
2088 eb->IInputObject_iface.lpVtbl = &vt_IInputObject;
2090 /* Default settings */
2091 eb->navpane.show = TRUE;
2093 list_init(&eb->event_clients);
2094 list_init(&eb->travellog);
2096 ret = IExplorerBrowser_QueryInterface(&eb->IExplorerBrowser_iface, riid, ppv);
2097 IExplorerBrowser_Release(&eb->IExplorerBrowser_iface);
2099 TRACE("--(%p)\n", ppv);
2100 return ret;