mmsystem.dll16: Fix the pointer arithmetic and memory leak issues when unmapping.
[wine.git] / dlls / shell32 / ebrowser.c
blobaee180426f4ad44f0cc35b2edeec664fae2ada40
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
25 #define NONAMELESSSTRUCT
27 #include "winerror.h"
28 #include "windef.h"
29 #include "winbase.h"
31 #include "wine/list.h"
32 #include "wine/debug.h"
33 #include "debughlp.h"
35 #include "shell32_main.h"
36 #include "pidl.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(shell);
40 #define SPLITTER_WIDTH 2
41 #define NP_MIN_WIDTH 60
42 #define SV_MIN_WIDTH 150
44 typedef struct _event_client {
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 IShellView *psv;
88 RECT sv_rc;
89 LPITEMIDLIST current_pidl;
91 IUnknown *punk_site;
92 ICommDlgBrowser *pcdb_site;
93 ICommDlgBrowser2 *pcdb2_site;
94 ICommDlgBrowser3 *pcdb3_site;
95 IExplorerPaneVisibility *pepv_site;
96 } ExplorerBrowserImpl;
98 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc);
100 /**************************************************************************
101 * Event functions.
103 static void events_unadvise_all(ExplorerBrowserImpl *This)
105 event_client *client, *curs;
106 TRACE("%p\n", This);
108 LIST_FOR_EACH_ENTRY_SAFE(client, curs, &This->event_clients, event_client, entry)
110 TRACE("Removing %p\n", client);
111 list_remove(&client->entry);
112 IExplorerBrowserEvents_Release(client->pebe);
113 HeapFree(GetProcessHeap(), 0, client);
117 static HRESULT events_NavigationPending(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
119 event_client *cursor;
120 HRESULT hres = S_OK;
122 TRACE("%p\n", This);
124 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
126 TRACE("Notifying %p\n", cursor);
127 hres = IExplorerBrowserEvents_OnNavigationPending(cursor->pebe, pidl);
129 /* If this failed for any reason, the browsing is supposed to be aborted. */
130 if(FAILED(hres))
131 break;
134 return hres;
137 static void events_NavigationComplete(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
139 event_client *cursor;
141 TRACE("%p\n", This);
143 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
145 TRACE("Notifying %p\n", cursor);
146 IExplorerBrowserEvents_OnNavigationComplete(cursor->pebe, pidl);
150 static void events_NavigationFailed(ExplorerBrowserImpl *This, PCIDLIST_ABSOLUTE pidl)
152 event_client *cursor;
154 TRACE("%p\n", This);
156 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
158 TRACE("Notifying %p\n", cursor);
159 IExplorerBrowserEvents_OnNavigationFailed(cursor->pebe, pidl);
163 static void events_ViewCreated(ExplorerBrowserImpl *This, IShellView *psv)
165 event_client *cursor;
167 TRACE("%p\n", This);
169 LIST_FOR_EACH_ENTRY(cursor, &This->event_clients, event_client, entry)
171 TRACE("Notifying %p\n", cursor);
172 IExplorerBrowserEvents_OnViewCreated(cursor->pebe, psv);
176 /**************************************************************************
177 * Travellog functions.
179 static void travellog_remove_entry(ExplorerBrowserImpl *This, travellog_entry *entry)
181 TRACE("Removing %p\n", entry);
183 list_remove(&entry->entry);
184 ILFree(entry->pidl);
185 HeapFree(GetProcessHeap(), 0, entry);
186 This->travellog_count--;
189 static void travellog_remove_all_entries(ExplorerBrowserImpl *This)
191 travellog_entry *cursor, *cursor2;
192 TRACE("%p\n", This);
194 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
195 travellog_remove_entry(This, cursor);
197 This->travellog_cursor = NULL;
200 static void travellog_add_entry(ExplorerBrowserImpl *This, LPITEMIDLIST pidl)
202 travellog_entry *new, *cursor, *cursor2;
203 TRACE("%p (old count %d)\n", pidl, This->travellog_count);
205 /* Replace the old tail, if any, with the new entry */
206 if(This->travellog_cursor)
208 LIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, &This->travellog, travellog_entry, entry)
210 if(cursor == This->travellog_cursor)
211 break;
212 travellog_remove_entry(This, cursor);
216 /* Create and add the new entry */
217 new = HeapAlloc(GetProcessHeap(), 0, sizeof(travellog_entry));
218 new->pidl = ILClone(pidl);
219 list_add_tail(&This->travellog, &new->entry);
220 This->travellog_cursor = new;
221 This->travellog_count++;
223 /* Remove the first few entries if the size limit is reached. */
224 if(This->travellog_count > 200)
226 UINT i = 0;
227 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->travellog, travellog_entry, entry)
229 if(i++ > 10)
230 break;
231 travellog_remove_entry(This, cursor);
236 static LPCITEMIDLIST travellog_go_back(ExplorerBrowserImpl *This)
238 travellog_entry *prev;
239 TRACE("%p, %p\n", This, This->travellog_cursor);
241 if(!This->travellog_cursor)
242 return NULL;
244 prev = LIST_ENTRY(list_prev(&This->travellog, &This->travellog_cursor->entry),
245 travellog_entry, entry);
246 if(!prev)
247 return NULL;
249 This->travellog_cursor = prev;
250 return prev->pidl;
253 static LPCITEMIDLIST travellog_go_forward(ExplorerBrowserImpl *This)
255 travellog_entry *next;
256 TRACE("%p, %p\n", This, This->travellog_cursor);
258 if(!This->travellog_cursor)
259 return NULL;
261 next = LIST_ENTRY(list_next(&This->travellog, &This->travellog_cursor->entry),
262 travellog_entry, entry);
263 if(!next)
264 return NULL;
266 This->travellog_cursor = next;
267 return next->pidl;
270 /**************************************************************************
271 * Helper functions
273 static void update_layout(ExplorerBrowserImpl *This)
275 RECT rc;
276 INT navpane_width_actual;
277 INT shellview_width_actual;
278 TRACE("%p (navpane: %d, EBO_SHOWFRAMES: %d)\n",
279 This, This->navpane.show, This->eb_options & EBO_SHOWFRAMES);
281 GetClientRect(This->hwnd_main, &rc);
283 if((This->eb_options & EBO_SHOWFRAMES) && This->navpane.show)
284 navpane_width_actual = This->navpane.width;
285 else
286 navpane_width_actual = 0;
288 shellview_width_actual = rc.right - navpane_width_actual;
289 if(shellview_width_actual < SV_MIN_WIDTH && navpane_width_actual)
291 INT missing_width = SV_MIN_WIDTH - shellview_width_actual;
292 if(missing_width < (navpane_width_actual - NP_MIN_WIDTH))
294 /* Shrink the navpane */
295 navpane_width_actual -= missing_width;
296 shellview_width_actual += missing_width;
298 else
300 /* Hide the navpane */
301 shellview_width_actual += navpane_width_actual;
302 navpane_width_actual = 0;
306 /**************************************************************
307 * Calculate rectangles for the panes. All rectangles contain
308 * the position of the panes relative to hwnd_main.
311 if(navpane_width_actual)
313 This->navpane.rc.left = This->navpane.rc.top = 0;
314 This->navpane.rc.right = navpane_width_actual;
315 This->navpane.rc.bottom = rc.bottom;
317 if(!This->navpane.hwnd_splitter)
318 initialize_navpane(This, This->hwnd_main, &This->navpane.rc);
320 else
321 ZeroMemory(&This->navpane.rc, sizeof(RECT));
323 This->sv_rc.left = navpane_width_actual;
324 This->sv_rc.top = 0;
325 This->sv_rc.right = This->sv_rc.left + shellview_width_actual;
326 This->sv_rc.bottom = rc.bottom;
329 static void size_panes(ExplorerBrowserImpl *This)
331 MoveWindow(This->navpane.hwnd_splitter,
332 This->navpane.rc.right - SPLITTER_WIDTH, This->navpane.rc.top,
333 SPLITTER_WIDTH, This->navpane.rc.bottom - This->navpane.rc.top,
334 TRUE);
336 MoveWindow(This->hwnd_sv,
337 This->sv_rc.left, This->sv_rc.top,
338 This->sv_rc.right - This->sv_rc.left, This->sv_rc.bottom - This->sv_rc.top,
339 TRUE);
342 static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
344 IFolderView *pfv;
345 HRESULT hr;
347 if(!This->psv)
348 return E_FAIL;
350 hr = IShellView_QueryInterface(This->psv, &IID_IFolderView, (void*)&pfv);
351 if(SUCCEEDED(hr))
353 hr = IFolderView_SetCurrentViewMode(pfv, This->fs.ViewMode);
354 IFolderView_Release(pfv);
357 return hr;
360 static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi)
362 IShellBrowser *psb = &This->IShellBrowser_iface;
363 IShellFolder *psf;
364 IShellView *psv;
365 HWND hwnd_new;
366 HRESULT hr;
368 TRACE("%p, %p\n", This, psi);
370 hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFObject, &IID_IShellFolder, (void**)&psf);
371 if(SUCCEEDED(hr))
373 hr = IShellFolder_CreateViewObject(psf, This->hwnd_main, &IID_IShellView, (void**)&psv);
374 if(SUCCEEDED(hr))
376 if(This->hwnd_sv)
378 IShellView_DestroyViewWindow(This->psv);
379 This->hwnd_sv = NULL;
382 hr = IShellView_CreateViewWindow(psv, This->psv, &This->fs, psb, &This->sv_rc, &hwnd_new);
383 if(SUCCEEDED(hr))
385 /* Replace the old shellview */
386 if(This->psv) IShellView_Release(This->psv);
388 This->psv = psv;
389 This->hwnd_sv = hwnd_new;
390 events_ViewCreated(This, psv);
392 else
394 ERR("CreateViewWindow failed (0x%x)\n", hr);
395 IShellView_Release(psv);
398 else
399 ERR("CreateViewObject failed (0x%x)\n", hr);
401 IShellFolder_Release(psf);
403 else
404 ERR("SI::BindToHandler failed (0x%x)\n", hr);
406 return hr;
409 static void get_interfaces_from_site(ExplorerBrowserImpl *This)
411 IServiceProvider *psp;
412 HRESULT hr;
414 /* Calling this with This->punk_site set to NULL should properly
415 * release any previously fetched interfaces.
418 if(This->pcdb_site)
420 IUnknown_Release(This->pcdb_site);
421 if(This->pcdb2_site) IUnknown_Release(This->pcdb2_site);
422 if(This->pcdb3_site) IUnknown_Release(This->pcdb3_site);
424 This->pcdb_site = NULL;
425 This->pcdb2_site = NULL;
426 This->pcdb3_site = NULL;
429 if(This->pepv_site)
431 IExplorerPaneVisibility_Release(This->pepv_site);
432 This->pepv_site = NULL;
435 if(!This->punk_site)
436 return;
438 hr = IUnknown_QueryInterface(This->punk_site, &IID_IServiceProvider, (void**)&psp);
439 if(FAILED(hr))
441 ERR("Failed to get IServiceProvider from site.\n");
442 return;
445 /* ICommDlgBrowser */
446 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser,
447 (void**)&This->pcdb_site);
448 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser2,
449 (void**)&This->pcdb2_site);
450 IServiceProvider_QueryService(psp, &SID_SExplorerBrowserFrame, &IID_ICommDlgBrowser3,
451 (void**)&This->pcdb3_site);
453 /* IExplorerPaneVisibility */
454 IServiceProvider_QueryService(psp, &SID_ExplorerPaneVisibility, &IID_IExplorerPaneVisibility,
455 (void**)&This->pepv_site);
457 IServiceProvider_Release(psp);
460 /**************************************************************************
461 * General pane functionality.
463 static void update_panestate(ExplorerBrowserImpl *This)
465 EXPLORERPANESTATE eps = EPS_DONTCARE;
466 BOOL show_navpane;
467 TRACE("%p\n", This);
469 if(!This->pepv_site) return;
471 IExplorerPaneVisibility_GetPaneState(This->pepv_site, (REFEXPLORERPANE) &EP_NavPane, &eps);
472 if( !(eps & EPS_DEFAULT_OFF) )
473 show_navpane = TRUE;
474 else
475 show_navpane = FALSE;
477 if(This->navpane.show != show_navpane)
479 update_layout(This);
480 size_panes(This);
483 This->navpane.show = show_navpane;
486 static void splitter_draw(HWND hwnd, RECT *rc)
488 HDC hdc = GetDC(hwnd);
489 InvertRect(hdc, rc);
490 ReleaseDC(hwnd, hdc);
493 /**************************************************************************
494 * The Navigation Pane.
496 static LRESULT navpane_splitter_beginresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
498 TRACE("\n");
500 SetCapture(hwnd);
502 CopyRect(&This->splitter_rc, &This->navpane.rc);
503 This->splitter_rc.left = This->splitter_rc.right - SPLITTER_WIDTH;
505 splitter_draw(GetParent(hwnd), &This->splitter_rc);
507 return TRUE;
510 static LRESULT navpane_splitter_resizing(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
512 int new_width, dx;
513 RECT rc;
515 if(GetCapture() != hwnd) return FALSE;
517 dx = (SHORT)LOWORD(lParam);
518 TRACE("%d.\n", dx);
520 CopyRect(&rc, &This->navpane.rc);
522 new_width = This->navpane.width + dx;
523 if(new_width > NP_MIN_WIDTH && This->sv_rc.right - new_width > SV_MIN_WIDTH)
525 rc.right = new_width;
526 rc.left = rc.right - SPLITTER_WIDTH;
527 splitter_draw(GetParent(hwnd), &This->splitter_rc);
528 splitter_draw(GetParent(hwnd), &rc);
529 CopyRect(&This->splitter_rc, &rc);
532 return TRUE;
535 static LRESULT navpane_splitter_endresize(ExplorerBrowserImpl *This, HWND hwnd, LPARAM lParam)
537 int new_width, dx;
539 if(GetCapture() != hwnd) return FALSE;
541 dx = (SHORT)LOWORD(lParam);
542 TRACE("%d.\n", dx);
544 splitter_draw(GetParent(hwnd), &This->splitter_rc);
546 new_width = This->navpane.width + dx;
547 if(new_width < NP_MIN_WIDTH)
548 new_width = NP_MIN_WIDTH;
549 else if(This->sv_rc.right - new_width < SV_MIN_WIDTH)
550 new_width = This->sv_rc.right - SV_MIN_WIDTH;
552 This->navpane.width = new_width;
554 update_layout(This);
555 size_panes(This);
557 ReleaseCapture();
559 return TRUE;
562 static LRESULT navpane_on_wm_create(HWND hwnd, CREATESTRUCTW *crs)
564 ExplorerBrowserImpl *This = crs->lpCreateParams;
565 INameSpaceTreeControl2 *pnstc2;
566 DWORD style;
567 HRESULT hr;
569 TRACE("%p\n", This);
570 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LPARAM)This);
571 This->navpane.hwnd_splitter = hwnd;
573 hr = CoCreateInstance(&CLSID_NamespaceTreeControl, NULL, CLSCTX_INPROC_SERVER,
574 &IID_INameSpaceTreeControl2, (void**)&pnstc2);
576 if(SUCCEEDED(hr))
578 style = NSTCS_HASEXPANDOS | NSTCS_ROOTHASEXPANDO | NSTCS_SHOWSELECTIONALWAYS;
579 hr = INameSpaceTreeControl2_Initialize(pnstc2, GetParent(hwnd), NULL, style);
580 if(SUCCEEDED(hr))
582 INameSpaceTreeControlEvents *pnstce;
583 IShellFolder *psfdesktop;
584 IShellItem *psi;
585 IOleWindow *pow;
586 LPITEMIDLIST pidl;
587 DWORD cookie, style2 = NSTCS2_DISPLAYPADDING;
589 hr = INameSpaceTreeControl2_SetControlStyle2(pnstc2, 0xFF, style2);
590 if(FAILED(hr))
591 ERR("SetControlStyle2 failed (0x%08x)\n", hr);
593 hr = INameSpaceTreeControl2_QueryInterface(pnstc2, &IID_IOleWindow, (void**)&pow);
594 if(SUCCEEDED(hr))
596 IOleWindow_GetWindow(pow, &This->navpane.hwnd_nstc);
597 IOleWindow_Release(pow);
599 else
600 ERR("QueryInterface(IOleWindow) failed (0x%08x)\n", hr);
602 pnstce = &This->INameSpaceTreeControlEvents_iface;
603 hr = INameSpaceTreeControl2_TreeAdvise(pnstc2, (IUnknown*)pnstce, &cookie);
604 if(FAILED(hr))
605 ERR("TreeAdvise failed. (0x%08x).\n", hr);
608 * Add the default roots
611 /* TODO: This should be FOLDERID_Links */
612 hr = SHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
613 if(SUCCEEDED(hr))
615 hr = SHCreateShellItem(NULL, NULL, pidl, &psi);
616 if(SUCCEEDED(hr))
618 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_NONFOLDERS, NSTCRS_VISIBLE, NULL);
619 IShellItem_Release(psi);
621 ILFree(pidl);
624 SHGetDesktopFolder(&psfdesktop);
625 hr = SHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
626 IShellFolder_Release(psfdesktop);
627 if(SUCCEEDED(hr))
629 hr = INameSpaceTreeControl2_AppendRoot(pnstc2, psi, SHCONTF_FOLDERS, NSTCRS_EXPANDED, NULL);
630 IShellItem_Release(psi);
633 /* TODO:
634 * We should advertise IID_INameSpaceTreeControl to the site of the
635 * host through its IProfferService interface, if any.
638 This->navpane.pnstc2 = pnstc2;
639 This->navpane.nstc_cookie = cookie;
641 return TRUE;
645 This->navpane.pnstc2 = NULL;
646 ERR("Failed (0x%08x)\n", hr);
648 return FALSE;
651 static LRESULT navpane_on_wm_size_move(ExplorerBrowserImpl *This)
653 UINT height, width;
654 TRACE("%p\n", This);
656 width = This->navpane.rc.right - This->navpane.rc.left - SPLITTER_WIDTH;
657 height = This->navpane.rc.bottom - This->navpane.rc.top;
659 MoveWindow(This->navpane.hwnd_nstc,
660 This->navpane.rc.left, This->navpane.rc.top,
661 width, height,
662 TRUE);
664 return FALSE;
667 static LRESULT navpane_on_wm_destroy(ExplorerBrowserImpl *This)
669 INameSpaceTreeControl_TreeUnadvise(This->navpane.pnstc2, This->navpane.nstc_cookie);
670 INameSpaceTreeControl_Release(This->navpane.pnstc2);
671 This->navpane.pnstc2 = NULL;
672 return TRUE;
675 static LRESULT CALLBACK navpane_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
677 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
679 switch(uMessage) {
680 case WM_CREATE: return navpane_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
681 case WM_MOVE: /* Fall through */
682 case WM_SIZE: return navpane_on_wm_size_move(This);
683 case WM_DESTROY: return navpane_on_wm_destroy(This);
684 case WM_LBUTTONDOWN: return navpane_splitter_beginresize(This, hWnd, lParam);
685 case WM_MOUSEMOVE: return navpane_splitter_resizing(This, hWnd, lParam);
686 case WM_LBUTTONUP: return navpane_splitter_endresize(This, hWnd, lParam);
687 default:
688 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
690 return 0;
693 static void initialize_navpane(ExplorerBrowserImpl *This, HWND hwnd_parent, RECT *rc)
695 WNDCLASSW wc;
696 HWND splitter;
697 static const WCHAR navpane_classname[] = {'e','b','_','n','a','v','p','a','n','e',0};
699 if( !GetClassInfoW(shell32_hInstance, navpane_classname, &wc) )
701 wc.style = CS_HREDRAW | CS_VREDRAW;
702 wc.lpfnWndProc = navpane_wndproc;
703 wc.cbClsExtra = 0;
704 wc.cbWndExtra = 0;
705 wc.hInstance = shell32_hInstance;
706 wc.hIcon = 0;
707 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_SIZEWE);
708 wc.hbrBackground = (HBRUSH)(COLOR_HIGHLIGHT + 1);
709 wc.lpszMenuName = NULL;
710 wc.lpszClassName = navpane_classname;
712 if (!RegisterClassW(&wc)) return;
715 splitter = CreateWindowExW(0, navpane_classname, NULL,
716 WS_CHILD | WS_TABSTOP | WS_VISIBLE,
717 rc->right - SPLITTER_WIDTH, rc->top,
718 SPLITTER_WIDTH, rc->bottom - rc->top,
719 hwnd_parent, 0, shell32_hInstance, This);
720 if(!splitter)
721 ERR("Failed to create navpane : %d.\n", GetLastError());
724 /**************************************************************************
725 * Main window related functions.
727 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
729 ExplorerBrowserImpl *This = crs->lpCreateParams;
730 TRACE("%p\n", This);
732 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
733 This->hwnd_main = hWnd;
735 return TRUE;
738 static LRESULT main_on_wm_size(ExplorerBrowserImpl *This)
740 update_layout(This);
741 size_panes(This);
743 return TRUE;
746 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
748 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
750 switch(uMessage)
752 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
753 case WM_SIZE: return main_on_wm_size(This);
754 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
757 return 0;
760 /**************************************************************************
761 * IExplorerBrowser Implementation
764 static inline ExplorerBrowserImpl *impl_from_IExplorerBrowser(IExplorerBrowser *iface)
766 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IExplorerBrowser_iface);
769 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
770 REFIID riid, void **ppvObject)
772 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
773 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
775 *ppvObject = NULL;
776 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
777 IsEqualIID(riid, &IID_IUnknown))
779 *ppvObject = This;
781 else if(IsEqualIID(riid, &IID_IShellBrowser))
783 *ppvObject = &This->IShellBrowser_iface;
785 else if(IsEqualIID(riid, &IID_ICommDlgBrowser) ||
786 IsEqualIID(riid, &IID_ICommDlgBrowser2) ||
787 IsEqualIID(riid, &IID_ICommDlgBrowser3))
789 *ppvObject = &This->ICommDlgBrowser3_iface;
791 else if(IsEqualIID(riid, &IID_IObjectWithSite))
793 *ppvObject = &This->IObjectWithSite_iface;
795 else if(IsEqualIID(riid, &IID_IInputObject))
797 *ppvObject = &This->IInputObject_iface;
800 if(*ppvObject)
802 IUnknown_AddRef((IUnknown*)*ppvObject);
803 return S_OK;
806 return E_NOINTERFACE;
809 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
811 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
812 LONG ref = InterlockedIncrement(&This->ref);
813 TRACE("%p - ref %d\n", This, ref);
815 return ref;
818 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
820 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
821 LONG ref = InterlockedDecrement(&This->ref);
822 TRACE("%p - ref %d\n", This, ref);
824 if(!ref)
826 TRACE("Freeing.\n");
828 if(!This->destroyed)
829 IExplorerBrowser_Destroy(iface);
831 IObjectWithSite_SetSite(&This->IObjectWithSite_iface, NULL);
833 HeapFree(GetProcessHeap(), 0, This);
834 return 0;
837 return ref;
840 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
841 HWND hwndParent, const RECT *prc,
842 const FOLDERSETTINGS *pfs)
844 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
845 WNDCLASSW wc;
846 LONG style;
847 static const WCHAR EB_CLASS_NAME[] =
848 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
850 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
852 if(This->hwnd_main)
853 return E_UNEXPECTED;
855 if(!hwndParent)
856 return E_INVALIDARG;
858 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
860 wc.style = CS_HREDRAW | CS_VREDRAW;
861 wc.lpfnWndProc = main_wndproc;
862 wc.cbClsExtra = 0;
863 wc.cbWndExtra = 0;
864 wc.hInstance = shell32_hInstance;
865 wc.hIcon = 0;
866 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
867 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
868 wc.lpszMenuName = NULL;
869 wc.lpszClassName = EB_CLASS_NAME;
871 if (!RegisterClassW(&wc)) return E_FAIL;
874 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
875 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
876 prc->left, prc->top,
877 prc->right - prc->left, prc->bottom - prc->top,
878 hwndParent, 0, shell32_hInstance, This);
880 if(!This->hwnd_main)
882 ERR("Failed to create the window.\n");
883 return E_FAIL;
886 This->fs.ViewMode = pfs ? pfs->ViewMode : FVM_DETAILS;
887 This->fs.fFlags = pfs ? (pfs->fFlags | FWF_NOCLIENTEDGE) : FWF_NOCLIENTEDGE;
889 return S_OK;
892 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
894 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
895 TRACE("%p\n", This);
897 if(This->psv)
899 IShellView_DestroyViewWindow(This->psv);
900 IShellView_Release(This->psv);
901 This->psv = NULL;
902 This->hwnd_sv = NULL;
905 events_unadvise_all(This);
906 travellog_remove_all_entries(This);
908 ILFree(This->current_pidl);
909 This->current_pidl = NULL;
911 DestroyWindow(This->hwnd_main);
912 This->destroyed = TRUE;
914 return S_OK;
917 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
918 HDWP *phdwp, RECT rcBrowser)
920 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
921 TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
923 if(phdwp && *phdwp)
925 *phdwp = DeferWindowPos(*phdwp, This->hwnd_main, NULL, rcBrowser.left, rcBrowser.top,
926 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top,
927 SWP_NOZORDER | SWP_NOACTIVATE);
928 if(!*phdwp)
929 return E_FAIL;
931 else
933 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
934 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
937 return S_OK;
940 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
941 LPCWSTR pszPropertyBag)
943 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
944 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
946 if(!pszPropertyBag)
947 return E_INVALIDARG;
949 /* FIXME: This method is currently useless as we don't save any
950 * settings anywhere, but at least one application breaks if we
951 * return E_NOTIMPL.
954 return S_OK;
957 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
958 LPCWSTR pszEmptyText)
960 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
961 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
963 return E_NOTIMPL;
966 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
967 const FOLDERSETTINGS *pfs)
969 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
970 TRACE("%p (%p)\n", This, pfs);
972 if(!pfs)
973 return E_INVALIDARG;
975 This->fs.ViewMode = pfs->ViewMode;
976 This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
978 /* Change the settings of the current view, if any. */
979 return change_viewmode(This, This->fs.ViewMode);
982 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
983 IExplorerBrowserEvents *psbe,
984 DWORD *pdwCookie)
986 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
987 event_client *client;
988 TRACE("%p (%p, %p)\n", This, psbe, pdwCookie);
990 client = HeapAlloc(GetProcessHeap(), 0, sizeof(event_client));
991 client->pebe = psbe;
992 client->cookie = ++This->events_next_cookie;
994 IExplorerBrowserEvents_AddRef(psbe);
995 *pdwCookie = client->cookie;
997 list_add_tail(&This->event_clients, &client->entry);
999 return S_OK;
1002 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
1003 DWORD dwCookie)
1005 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1006 event_client *client;
1007 TRACE("%p (0x%x)\n", This, dwCookie);
1009 LIST_FOR_EACH_ENTRY(client, &This->event_clients, event_client, entry)
1011 if(client->cookie == dwCookie)
1013 list_remove(&client->entry);
1014 IExplorerBrowserEvents_Release(client->pebe);
1015 HeapFree(GetProcessHeap(), 0, client);
1016 return S_OK;
1020 return E_INVALIDARG;
1023 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
1024 EXPLORER_BROWSER_OPTIONS dwFlag)
1026 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1027 static const EXPLORER_BROWSER_OPTIONS unsupported_options =
1028 EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW;
1030 TRACE("%p (0x%x)\n", This, dwFlag);
1032 if(dwFlag & unsupported_options)
1033 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag);
1035 This->eb_options = dwFlag;
1037 return S_OK;
1040 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
1041 EXPLORER_BROWSER_OPTIONS *pdwFlag)
1043 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1044 TRACE("%p (%p)\n", This, pdwFlag);
1046 *pdwFlag = This->eb_options;
1048 return S_OK;
1051 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
1052 PCUIDLIST_RELATIVE pidl,
1053 UINT uFlags)
1055 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1056 LPITEMIDLIST absolute_pidl = NULL;
1057 HRESULT hr;
1058 static const UINT unsupported_browse_flags =
1059 SBSP_NEWBROWSER | EBF_SELECTFROMDATAOBJECT | EBF_NODROPTARGET;
1060 TRACE("%p (%p, 0x%x)\n", This, pidl, uFlags);
1062 if(!This->hwnd_main)
1063 return E_FAIL;
1065 if(This->destroyed)
1066 return HRESULT_FROM_WIN32(ERROR_BUSY);
1068 if(This->current_pidl && (This->eb_options & EBO_NAVIGATEONCE))
1069 return E_FAIL;
1071 if(uFlags & SBSP_EXPLOREMODE)
1072 return E_INVALIDARG;
1074 if(uFlags & unsupported_browse_flags)
1075 FIXME("Argument 0x%x contains unsupported flags.\n", uFlags);
1077 if(uFlags & SBSP_NAVIGATEBACK)
1079 TRACE("SBSP_NAVIGATEBACK\n");
1080 absolute_pidl = ILClone(travellog_go_back(This));
1081 if(!absolute_pidl && !This->current_pidl)
1082 return E_FAIL;
1083 else if(!absolute_pidl)
1084 return S_OK;
1087 else if(uFlags & SBSP_NAVIGATEFORWARD)
1089 TRACE("SBSP_NAVIGATEFORWARD\n");
1090 absolute_pidl = ILClone(travellog_go_forward(This));
1091 if(!absolute_pidl && !This->current_pidl)
1092 return E_FAIL;
1093 else if(!absolute_pidl)
1094 return S_OK;
1097 else if(uFlags & SBSP_PARENT)
1099 if(This->current_pidl)
1101 if(_ILIsPidlSimple(This->current_pidl))
1103 absolute_pidl = _ILCreateDesktop();
1105 else
1107 absolute_pidl = ILClone(This->current_pidl);
1108 ILRemoveLastID(absolute_pidl);
1111 if(!absolute_pidl)
1113 ERR("Failed to get parent pidl.\n");
1114 return E_FAIL;
1118 else if(uFlags & SBSP_RELATIVE)
1120 /* SBSP_RELATIVE has precedence over SBSP_ABSOLUTE */
1121 TRACE("SBSP_RELATIVE\n");
1122 if(This->current_pidl)
1124 absolute_pidl = ILCombine(This->current_pidl, pidl);
1126 if(!absolute_pidl)
1128 ERR("Failed to get absolute pidl.\n");
1129 return E_FAIL;
1132 else
1134 TRACE("SBSP_ABSOLUTE\n");
1135 absolute_pidl = ILClone(pidl);
1136 if(!absolute_pidl && !This->current_pidl)
1137 return E_INVALIDARG;
1138 else if(!absolute_pidl)
1139 return S_OK;
1142 /* TODO: Asynchronous browsing. Return S_OK here and finish in
1143 * another thread. */
1145 hr = events_NavigationPending(This, absolute_pidl);
1146 if(FAILED(hr))
1148 TRACE("Browsing aborted.\n");
1149 ILFree(absolute_pidl);
1150 return E_FAIL;
1153 get_interfaces_from_site(This);
1154 update_panestate(This);
1156 /* Only browse if the new pidl differs from the old */
1157 if(!ILIsEqual(This->current_pidl, absolute_pidl))
1159 IShellItem *psi;
1160 hr = SHCreateItemFromIDList(absolute_pidl, &IID_IShellItem, (void**)&psi);
1161 if(SUCCEEDED(hr))
1163 hr = create_new_shellview(This, psi);
1164 if(FAILED(hr))
1166 events_NavigationFailed(This, absolute_pidl);
1167 ILFree(absolute_pidl);
1168 IShellItem_Release(psi);
1169 return E_FAIL;
1172 /* Add to travellog */
1173 if( !(This->eb_options & EBO_NOTRAVELLOG) &&
1174 !(uFlags & (SBSP_NAVIGATEFORWARD|SBSP_NAVIGATEBACK)) )
1176 travellog_add_entry(This, absolute_pidl);
1179 IShellItem_Release(psi);
1183 events_NavigationComplete(This, absolute_pidl);
1184 ILFree(This->current_pidl);
1185 This->current_pidl = absolute_pidl;
1187 /* Expand the NameSpaceTree to the current location. */
1188 if(This->navpane.show && This->navpane.pnstc2)
1190 IShellItem *psi;
1191 hr = SHCreateItemFromIDList(This->current_pidl, &IID_IShellItem, (void**)&psi);
1192 if(SUCCEEDED(hr))
1194 INameSpaceTreeControl_EnsureItemVisible(This->navpane.pnstc2, psi);
1195 IShellItem_Release(psi);
1199 return S_OK;
1202 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
1203 IUnknown *punk, UINT uFlags)
1205 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1206 LPITEMIDLIST pidl;
1207 HRESULT hr;
1208 TRACE("%p (%p, 0x%x)\n", This, punk, uFlags);
1210 if(!punk)
1211 return IExplorerBrowser_fnBrowseToIDList(iface, NULL, uFlags);
1213 hr = SHGetIDListFromObject(punk, &pidl);
1214 if(SUCCEEDED(hr))
1216 hr = IExplorerBrowser_BrowseToIDList(iface, pidl, uFlags);
1217 ILFree(pidl);
1220 return hr;
1223 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
1224 IUnknown *punk,
1225 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
1227 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1228 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
1230 return E_NOTIMPL;
1233 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
1235 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1236 FIXME("stub, %p\n", This);
1238 return E_NOTIMPL;
1241 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
1242 REFIID riid, void **ppv)
1244 ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
1245 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
1247 if(!This->psv)
1248 return E_FAIL;
1250 return IShellView_QueryInterface(This->psv, riid, ppv);
1253 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
1255 IExplorerBrowser_fnQueryInterface,
1256 IExplorerBrowser_fnAddRef,
1257 IExplorerBrowser_fnRelease,
1258 IExplorerBrowser_fnInitialize,
1259 IExplorerBrowser_fnDestroy,
1260 IExplorerBrowser_fnSetRect,
1261 IExplorerBrowser_fnSetPropertyBag,
1262 IExplorerBrowser_fnSetEmptyText,
1263 IExplorerBrowser_fnSetFolderSettings,
1264 IExplorerBrowser_fnAdvise,
1265 IExplorerBrowser_fnUnadvise,
1266 IExplorerBrowser_fnSetOptions,
1267 IExplorerBrowser_fnGetOptions,
1268 IExplorerBrowser_fnBrowseToIDList,
1269 IExplorerBrowser_fnBrowseToObject,
1270 IExplorerBrowser_fnFillFromObject,
1271 IExplorerBrowser_fnRemoveAll,
1272 IExplorerBrowser_fnGetCurrentView
1275 /**************************************************************************
1276 * IShellBrowser Implementation
1279 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
1281 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IShellBrowser_iface);
1284 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
1285 REFIID riid, void **ppvObject)
1287 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1288 TRACE("%p\n", This);
1289 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
1292 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
1294 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1295 TRACE("%p\n", This);
1296 return IUnknown_AddRef((IUnknown*) This);
1299 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
1301 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1302 TRACE("%p\n", This);
1303 return IUnknown_Release((IUnknown*) This);
1306 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
1308 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1309 TRACE("%p (%p)\n", This, phwnd);
1311 if(!This->hwnd_main)
1312 return E_FAIL;
1314 *phwnd = This->hwnd_main;
1315 return S_OK;
1318 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
1319 BOOL fEnterMode)
1321 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1322 FIXME("stub, %p (%d)\n", This, fEnterMode);
1324 return E_NOTIMPL;
1327 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
1328 HMENU hmenuShared,
1329 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1331 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1332 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
1334 /* Not implemented. */
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
1339 HMENU hmenuShared,
1340 HOLEMENU holemenuReserved,
1341 HWND hwndActiveObject)
1343 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1344 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
1346 /* Not implemented. */
1347 return E_NOTIMPL;
1350 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
1351 HMENU hmenuShared)
1353 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1354 TRACE("%p (%p)\n", This, hmenuShared);
1356 /* Not implemented. */
1357 return E_NOTIMPL;
1360 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
1361 LPCOLESTR pszStatusText)
1363 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1364 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
1366 return E_NOTIMPL;
1369 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
1370 BOOL fEnable)
1372 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1373 FIXME("stub, %p (%d)\n", This, fEnable);
1375 return E_NOTIMPL;
1378 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
1379 MSG *pmsg, WORD wID)
1381 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1382 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
1384 return E_NOTIMPL;
1387 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
1388 LPCITEMIDLIST pidl, UINT wFlags)
1390 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1391 TRACE("%p (%p, %x)\n", This, pidl, wFlags);
1393 return IExplorerBrowser_fnBrowseToIDList((IExplorerBrowser*)This, pidl, wFlags);
1396 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
1397 DWORD grfMode,
1398 IStream **ppStrm)
1400 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1401 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
1403 *ppStrm = NULL;
1404 return E_FAIL;
1407 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
1408 UINT id, HWND *phwnd)
1410 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1411 TRACE("%p (%d, %p)\n", This, id, phwnd);
1413 /* Not implemented. */
1414 return E_NOTIMPL;
1417 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
1418 UINT id, UINT uMsg,
1419 WPARAM wParam, LPARAM lParam,
1420 LRESULT *pret)
1422 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1423 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
1425 return E_NOTIMPL;
1428 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
1429 IShellView **ppshv)
1431 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1432 TRACE("%p (%p)\n", This, ppshv);
1434 if(!This->psv)
1435 return E_FAIL;
1437 *ppshv = This->psv;
1438 IShellView_AddRef(This->psv);
1440 return S_OK;
1443 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
1444 IShellView *pshv)
1446 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1447 FIXME("stub, %p (%p)\n", This, pshv);
1449 return E_NOTIMPL;
1452 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
1453 LPTBBUTTONSB lpButtons,
1454 UINT nButtons, UINT uFlags)
1456 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
1457 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
1459 return E_NOTIMPL;
1462 static const IShellBrowserVtbl vt_IShellBrowser = {
1463 IShellBrowser_fnQueryInterface,
1464 IShellBrowser_fnAddRef,
1465 IShellBrowser_fnRelease,
1466 IShellBrowser_fnGetWindow,
1467 IShellBrowser_fnContextSensitiveHelp,
1468 IShellBrowser_fnInsertMenusSB,
1469 IShellBrowser_fnSetMenuSB,
1470 IShellBrowser_fnRemoveMenusSB,
1471 IShellBrowser_fnSetStatusTextSB,
1472 IShellBrowser_fnEnableModelessSB,
1473 IShellBrowser_fnTranslateAcceleratorSB,
1474 IShellBrowser_fnBrowseObject,
1475 IShellBrowser_fnGetViewStateStream,
1476 IShellBrowser_fnGetControlWindow,
1477 IShellBrowser_fnSendControlMsg,
1478 IShellBrowser_fnQueryActiveShellView,
1479 IShellBrowser_fnOnViewWindowActive,
1480 IShellBrowser_fnSetToolbarItems
1483 /**************************************************************************
1484 * ICommDlgBrowser3 Implementation
1487 static inline ExplorerBrowserImpl *impl_from_ICommDlgBrowser3(ICommDlgBrowser3 *iface)
1489 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, ICommDlgBrowser3_iface);
1492 static HRESULT WINAPI ICommDlgBrowser3_fnQueryInterface(ICommDlgBrowser3 *iface,
1493 REFIID riid,
1494 void **ppvObject)
1496 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1497 TRACE("%p\n", This);
1498 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
1501 static ULONG WINAPI ICommDlgBrowser3_fnAddRef(ICommDlgBrowser3 *iface)
1503 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1504 TRACE("%p\n", This);
1505 return IUnknown_AddRef((IUnknown*) This);
1508 static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
1510 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1511 TRACE("%p\n", This);
1512 return IUnknown_Release((IUnknown*) This);
1515 static HRESULT WINAPI ICommDlgBrowser3_fnOnDefaultCommand(ICommDlgBrowser3 *iface,
1516 IShellView *shv)
1518 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1519 IDataObject *pdo;
1520 HRESULT hr;
1521 HRESULT ret = S_FALSE;
1523 TRACE("%p (%p)\n", This, shv);
1525 hr = IShellView_GetItemObject(shv, SVGIO_SELECTION, &IID_IDataObject, (void**)&pdo);
1526 if(SUCCEEDED(hr))
1528 FORMATETC fmt;
1529 STGMEDIUM medium;
1531 fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
1532 fmt.ptd = NULL;
1533 fmt.dwAspect = DVASPECT_CONTENT;
1534 fmt.lindex = -1;
1535 fmt.tymed = TYMED_HGLOBAL;
1537 hr = IDataObject_GetData(pdo, &fmt ,&medium);
1538 IDataObject_Release(pdo);
1539 if(SUCCEEDED(hr))
1541 LPIDA pida = GlobalLock(medium.u.hGlobal);
1542 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
1544 /* Handle folders by browsing to them. */
1545 if(_ILIsFolder(pidl_child) || _ILIsDrive(pidl_child) || _ILIsSpecialFolder(pidl_child))
1547 IExplorerBrowser_BrowseToIDList((IExplorerBrowser*)This, pidl_child, SBSP_RELATIVE);
1548 ret = S_OK;
1550 GlobalUnlock(medium.u.hGlobal);
1551 GlobalFree(medium.u.hGlobal);
1553 else
1554 ERR("Failed to get data from IDataObject.\n");
1555 } else
1556 ERR("Failed to get IDataObject.\n");
1558 /* If we didn't handle the default command, check if we have a
1559 * client that does */
1560 if(ret == S_FALSE && This->pcdb_site)
1561 return ICommDlgBrowser_OnDefaultCommand(This->pcdb_site, shv);
1563 return ret;
1565 static HRESULT WINAPI ICommDlgBrowser3_fnOnStateChange(ICommDlgBrowser3 *iface,
1566 IShellView *shv, ULONG uChange)
1568 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1569 TRACE("%p (%p, %d)\n", This, shv, uChange);
1571 if(This->pcdb_site)
1572 return ICommDlgBrowser_OnStateChange(This->pcdb_site, shv, uChange);
1574 return E_NOTIMPL;
1576 static HRESULT WINAPI ICommDlgBrowser3_fnIncludeObject(ICommDlgBrowser3 *iface,
1577 IShellView *pshv, LPCITEMIDLIST pidl)
1579 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1580 TRACE("%p (%p, %p)\n", This, pshv, pidl);
1582 if(This->pcdb_site)
1583 return ICommDlgBrowser_IncludeObject(This->pcdb_site, pshv, pidl);
1585 return S_OK;
1588 static HRESULT WINAPI ICommDlgBrowser3_fnNotify(ICommDlgBrowser3 *iface,
1589 IShellView *pshv,
1590 DWORD dwNotifyType)
1592 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1593 TRACE("%p (%p, 0x%x)\n", This, pshv, dwNotifyType);
1595 if(This->pcdb2_site)
1596 return ICommDlgBrowser2_Notify(This->pcdb2_site, pshv, dwNotifyType);
1598 return S_OK;
1601 static HRESULT WINAPI ICommDlgBrowser3_fnGetDefaultMenuText(ICommDlgBrowser3 *iface,
1602 IShellView *pshv,
1603 LPWSTR pszText, int cchMax)
1605 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1606 TRACE("%p (%p, %s, %d)\n", This, pshv, debugstr_w(pszText), cchMax);
1608 if(This->pcdb2_site)
1609 return ICommDlgBrowser2_GetDefaultMenuText(This->pcdb2_site, pshv, pszText, cchMax);
1611 return S_OK;
1614 static HRESULT WINAPI ICommDlgBrowser3_fnGetViewFlags(ICommDlgBrowser3 *iface,
1615 DWORD *pdwFlags)
1617 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1618 TRACE("%p (%p)\n", This, pdwFlags);
1620 if(This->pcdb2_site)
1621 return ICommDlgBrowser2_GetViewFlags(This->pcdb2_site, pdwFlags);
1623 return S_OK;
1626 static HRESULT WINAPI ICommDlgBrowser3_fnOnColumnClicked(ICommDlgBrowser3 *iface,
1627 IShellView *pshv, int iColumn)
1629 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1630 TRACE("%p (%p, %d)\n", This, pshv, iColumn);
1632 if(This->pcdb3_site)
1633 return ICommDlgBrowser3_OnColumnClicked(This->pcdb3_site, pshv, iColumn);
1635 return S_OK;
1638 static HRESULT WINAPI ICommDlgBrowser3_fnGetCurrentFilter(ICommDlgBrowser3 *iface,
1639 LPWSTR pszFileSpec,
1640 int cchFileSpec)
1642 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1643 TRACE("%p (%s, %d)\n", This, debugstr_w(pszFileSpec), cchFileSpec);
1645 if(This->pcdb3_site)
1646 return ICommDlgBrowser3_GetCurrentFilter(This->pcdb3_site, pszFileSpec, cchFileSpec);
1648 return S_OK;
1651 static HRESULT WINAPI ICommDlgBrowser3_fnOnPreviewCreated(ICommDlgBrowser3 *iface,
1652 IShellView *pshv)
1654 ExplorerBrowserImpl *This = impl_from_ICommDlgBrowser3(iface);
1655 TRACE("%p (%p)\n", This, pshv);
1657 if(This->pcdb3_site)
1658 return ICommDlgBrowser3_OnPreviewCreated(This->pcdb3_site, pshv);
1660 return S_OK;
1663 static const ICommDlgBrowser3Vtbl vt_ICommDlgBrowser3 = {
1664 ICommDlgBrowser3_fnQueryInterface,
1665 ICommDlgBrowser3_fnAddRef,
1666 ICommDlgBrowser3_fnRelease,
1667 ICommDlgBrowser3_fnOnDefaultCommand,
1668 ICommDlgBrowser3_fnOnStateChange,
1669 ICommDlgBrowser3_fnIncludeObject,
1670 ICommDlgBrowser3_fnNotify,
1671 ICommDlgBrowser3_fnGetDefaultMenuText,
1672 ICommDlgBrowser3_fnGetViewFlags,
1673 ICommDlgBrowser3_fnOnColumnClicked,
1674 ICommDlgBrowser3_fnGetCurrentFilter,
1675 ICommDlgBrowser3_fnOnPreviewCreated
1678 /**************************************************************************
1679 * IObjectWithSite Implementation
1682 static inline ExplorerBrowserImpl *impl_from_IObjectWithSite(IObjectWithSite *iface)
1684 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IObjectWithSite_iface);
1687 static HRESULT WINAPI IObjectWithSite_fnQueryInterface(IObjectWithSite *iface,
1688 REFIID riid, void **ppvObject)
1690 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1691 TRACE("%p\n", This);
1692 return IUnknown_QueryInterface((IUnknown*)This, riid, ppvObject);
1695 static ULONG WINAPI IObjectWithSite_fnAddRef(IObjectWithSite *iface)
1697 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1698 TRACE("%p\n", This);
1699 return IUnknown_AddRef((IUnknown*)This);
1702 static ULONG WINAPI IObjectWithSite_fnRelease(IObjectWithSite *iface)
1704 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1705 TRACE("%p\n", This);
1706 return IUnknown_Release((IUnknown*)This);
1709 static HRESULT WINAPI IObjectWithSite_fnSetSite(IObjectWithSite *iface, IUnknown *punk_site)
1711 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1712 TRACE("%p (%p)\n", This, punk_site);
1714 if(This->punk_site)
1716 IUnknown_Release(This->punk_site);
1717 This->punk_site = NULL;
1718 get_interfaces_from_site(This);
1721 This->punk_site = punk_site;
1723 if(This->punk_site)
1724 IUnknown_AddRef(This->punk_site);
1726 return S_OK;
1729 static HRESULT WINAPI IObjectWithSite_fnGetSite(IObjectWithSite *iface, REFIID riid, void **ppvSite)
1731 ExplorerBrowserImpl *This = impl_from_IObjectWithSite(iface);
1732 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvSite);
1734 if(!This->punk_site)
1735 return E_FAIL;
1737 return IUnknown_QueryInterface(This->punk_site, riid, ppvSite);
1740 static const IObjectWithSiteVtbl vt_IObjectWithSite = {
1741 IObjectWithSite_fnQueryInterface,
1742 IObjectWithSite_fnAddRef,
1743 IObjectWithSite_fnRelease,
1744 IObjectWithSite_fnSetSite,
1745 IObjectWithSite_fnGetSite
1748 /**************************************************************************
1749 * INameSpaceTreeControlEvents Implementation
1751 static inline ExplorerBrowserImpl *impl_from_INameSpaceTreeControlEvents(INameSpaceTreeControlEvents *iface)
1753 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, INameSpaceTreeControlEvents_iface);
1756 static HRESULT WINAPI NSTCEvents_fnQueryInterface(INameSpaceTreeControlEvents *iface,
1757 REFIID riid, void **ppvObject)
1759 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1760 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
1762 *ppvObject = NULL;
1763 if(IsEqualIID(riid, &IID_INameSpaceTreeControlEvents) ||
1764 IsEqualIID(riid, &IID_IUnknown))
1766 *ppvObject = iface;
1769 if(*ppvObject)
1771 IUnknown_AddRef((IUnknown*)*ppvObject);
1772 return S_OK;
1775 return E_NOINTERFACE;
1778 static ULONG WINAPI NSTCEvents_fnAddRef(INameSpaceTreeControlEvents *iface)
1780 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1781 TRACE("%p\n", This);
1782 return IUnknown_AddRef((IUnknown*)This);
1785 static ULONG WINAPI NSTCEvents_fnRelease(INameSpaceTreeControlEvents *iface)
1787 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1788 TRACE("%p\n", This);
1789 return IUnknown_Release((IUnknown*)This);
1792 static HRESULT WINAPI NSTCEvents_fnOnItemClick(INameSpaceTreeControlEvents *iface,
1793 IShellItem *psi,
1794 NSTCEHITTEST nstceHitTest,
1795 NSTCECLICKTYPE nstceClickType)
1797 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1798 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstceHitTest, nstceClickType);
1799 return S_OK;
1802 static HRESULT WINAPI NSTCEvents_fnOnPropertyItemCommit(INameSpaceTreeControlEvents *iface,
1803 IShellItem *psi)
1805 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1806 TRACE("%p (%p)\n", This, psi);
1807 return E_NOTIMPL;
1810 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanging(INameSpaceTreeControlEvents *iface,
1811 IShellItem *psi,
1812 NSTCITEMSTATE nstcisMask,
1813 NSTCITEMSTATE nstcisState)
1815 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1816 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1817 return E_NOTIMPL;
1820 static HRESULT WINAPI NSTCEvents_fnOnItemStateChanged(INameSpaceTreeControlEvents *iface,
1821 IShellItem *psi,
1822 NSTCITEMSTATE nstcisMask,
1823 NSTCITEMSTATE nstcisState)
1825 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1826 TRACE("%p (%p, 0x%x, 0x%x)\n", This, psi, nstcisMask, nstcisState);
1827 return E_NOTIMPL;
1830 static HRESULT WINAPI NSTCEvents_fnOnSelectionChanged(INameSpaceTreeControlEvents *iface,
1831 IShellItemArray *psiaSelection)
1833 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1834 IShellItem *psi;
1835 HRESULT hr;
1836 TRACE("%p (%p)\n", This, psiaSelection);
1838 hr = IShellItemArray_GetItemAt(psiaSelection, 0, &psi);
1839 if(SUCCEEDED(hr))
1841 hr = IExplorerBrowser_BrowseToObject((IExplorerBrowser*)This,
1842 (IUnknown*)psi, SBSP_DEFBROWSER);
1843 IShellItem_Release(psi);
1846 return hr;
1849 static HRESULT WINAPI NSTCEvents_fnOnKeyboardInput(INameSpaceTreeControlEvents *iface,
1850 UINT uMsg, WPARAM wParam, LPARAM lParam)
1852 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1853 TRACE("%p (%d, 0x%lx, 0x%lx)\n", This, uMsg, wParam, lParam);
1854 return S_OK;
1857 static HRESULT WINAPI NSTCEvents_fnOnBeforeExpand(INameSpaceTreeControlEvents *iface,
1858 IShellItem *psi)
1860 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1861 TRACE("%p (%p)\n", This, psi);
1862 return E_NOTIMPL;
1865 static HRESULT WINAPI NSTCEvents_fnOnAfterExpand(INameSpaceTreeControlEvents *iface,
1866 IShellItem *psi)
1868 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1869 TRACE("%p (%p)\n", This, psi);
1870 return E_NOTIMPL;
1873 static HRESULT WINAPI NSTCEvents_fnOnBeginLabelEdit(INameSpaceTreeControlEvents *iface,
1874 IShellItem *psi)
1876 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1877 TRACE("%p (%p)\n", This, psi);
1878 return E_NOTIMPL;
1881 static HRESULT WINAPI NSTCEvents_fnOnEndLabelEdit(INameSpaceTreeControlEvents *iface,
1882 IShellItem *psi)
1884 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1885 TRACE("%p (%p)\n", This, psi);
1886 return E_NOTIMPL;
1889 static HRESULT WINAPI NSTCEvents_fnOnGetToolTip(INameSpaceTreeControlEvents *iface,
1890 IShellItem *psi, LPWSTR pszTip, int cchTip)
1892 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1893 TRACE("%p (%p, %p, %d)\n", This, psi, pszTip, cchTip);
1894 return E_NOTIMPL;
1897 static HRESULT WINAPI NSTCEvents_fnOnBeforeItemDelete(INameSpaceTreeControlEvents *iface,
1898 IShellItem *psi)
1900 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1901 TRACE("%p (%p)\n", This, psi);
1902 return E_NOTIMPL;
1905 static HRESULT WINAPI NSTCEvents_fnOnItemAdded(INameSpaceTreeControlEvents *iface,
1906 IShellItem *psi, BOOL fIsRoot)
1908 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1909 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1910 return E_NOTIMPL;
1913 static HRESULT WINAPI NSTCEvents_fnOnItemDeleted(INameSpaceTreeControlEvents *iface,
1914 IShellItem *psi, BOOL fIsRoot)
1916 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1917 TRACE("%p (%p, %d)\n", This, psi, fIsRoot);
1918 return E_NOTIMPL;
1921 static HRESULT WINAPI NSTCEvents_fnOnBeforeContextMenu(INameSpaceTreeControlEvents *iface,
1922 IShellItem *psi, REFIID riid, void **ppv)
1924 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1925 TRACE("%p (%p, %s, %p)\n", This, psi, shdebugstr_guid(riid), ppv);
1926 return E_NOTIMPL;
1929 static HRESULT WINAPI NSTCEvents_fnOnAfterContextMenu(INameSpaceTreeControlEvents *iface,
1930 IShellItem *psi, IContextMenu *pcmIn,
1931 REFIID riid, void **ppv)
1933 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1934 TRACE("%p (%p, %p, %s, %p)\n", This, psi, pcmIn, shdebugstr_guid(riid), ppv);
1935 return E_NOTIMPL;
1938 static HRESULT WINAPI NSTCEvents_fnOnBeforeStateImageChange(INameSpaceTreeControlEvents *iface,
1939 IShellItem *psi)
1941 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1942 TRACE("%p (%p)\n", This, psi);
1943 return E_NOTIMPL;
1946 static HRESULT WINAPI NSTCEvents_fnOnGetDefaultIconIndex(INameSpaceTreeControlEvents* iface,
1947 IShellItem *psi,
1948 int *piDefaultIcon, int *piOpenIcon)
1950 ExplorerBrowserImpl *This = impl_from_INameSpaceTreeControlEvents(iface);
1951 TRACE("%p (%p, %p, %p)\n", This, psi, piDefaultIcon, piOpenIcon);
1952 return E_NOTIMPL;
1956 static const INameSpaceTreeControlEventsVtbl vt_INameSpaceTreeControlEvents = {
1957 NSTCEvents_fnQueryInterface,
1958 NSTCEvents_fnAddRef,
1959 NSTCEvents_fnRelease,
1960 NSTCEvents_fnOnItemClick,
1961 NSTCEvents_fnOnPropertyItemCommit,
1962 NSTCEvents_fnOnItemStateChanging,
1963 NSTCEvents_fnOnItemStateChanged,
1964 NSTCEvents_fnOnSelectionChanged,
1965 NSTCEvents_fnOnKeyboardInput,
1966 NSTCEvents_fnOnBeforeExpand,
1967 NSTCEvents_fnOnAfterExpand,
1968 NSTCEvents_fnOnBeginLabelEdit,
1969 NSTCEvents_fnOnEndLabelEdit,
1970 NSTCEvents_fnOnGetToolTip,
1971 NSTCEvents_fnOnBeforeItemDelete,
1972 NSTCEvents_fnOnItemAdded,
1973 NSTCEvents_fnOnItemDeleted,
1974 NSTCEvents_fnOnBeforeContextMenu,
1975 NSTCEvents_fnOnAfterContextMenu,
1976 NSTCEvents_fnOnBeforeStateImageChange,
1977 NSTCEvents_fnOnGetDefaultIconIndex
1980 /**************************************************************************
1981 * IInputObject Implementation
1984 static inline ExplorerBrowserImpl *impl_from_IInputObject(IInputObject *iface)
1986 return CONTAINING_RECORD(iface, ExplorerBrowserImpl, IInputObject_iface);
1989 static HRESULT WINAPI IInputObject_fnQueryInterface(IInputObject *iface,
1990 REFIID riid, void **ppvObject)
1992 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
1993 TRACE("%p\n", This);
1994 return IUnknown_QueryInterface((IUnknown*)This, riid, ppvObject);
1997 static ULONG WINAPI IInputObject_fnAddRef(IInputObject *iface)
1999 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2000 TRACE("%p\n", This);
2001 return IUnknown_AddRef((IUnknown*)This);
2004 static ULONG WINAPI IInputObject_fnRelease(IInputObject *iface)
2006 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2007 TRACE("%p\n", This);
2008 return IUnknown_Release((IUnknown*)This);
2011 static HRESULT WINAPI IInputObject_fnUIActivateIO(IInputObject *iface, BOOL fActivate, MSG *pMsg)
2013 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2014 FIXME("stub, %p (%d, %p)\n", This, fActivate, pMsg);
2015 return E_NOTIMPL;
2018 static HRESULT WINAPI IInputObject_fnHasFocusIO(IInputObject *iface)
2020 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2021 FIXME("stub, %p\n", This);
2022 return E_NOTIMPL;
2025 static HRESULT WINAPI IInputObject_fnTranslateAcceleratorIO(IInputObject *iface, MSG *pMsg)
2027 ExplorerBrowserImpl *This = impl_from_IInputObject(iface);
2028 FIXME("stub, %p (%p)\n", This, pMsg);
2029 return E_NOTIMPL;
2032 static IInputObjectVtbl vt_IInputObject = {
2033 IInputObject_fnQueryInterface,
2034 IInputObject_fnAddRef,
2035 IInputObject_fnRelease,
2036 IInputObject_fnUIActivateIO,
2037 IInputObject_fnHasFocusIO,
2038 IInputObject_fnTranslateAcceleratorIO
2041 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
2043 ExplorerBrowserImpl *eb;
2044 HRESULT ret;
2046 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
2048 if(!ppv)
2049 return E_POINTER;
2050 if(pUnkOuter)
2051 return CLASS_E_NOAGGREGATION;
2053 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
2054 eb->ref = 1;
2055 eb->IExplorerBrowser_iface.lpVtbl = &vt_IExplorerBrowser;
2056 eb->IShellBrowser_iface.lpVtbl = &vt_IShellBrowser;
2057 eb->ICommDlgBrowser3_iface.lpVtbl = &vt_ICommDlgBrowser3;
2058 eb->IObjectWithSite_iface.lpVtbl = &vt_IObjectWithSite;
2059 eb->INameSpaceTreeControlEvents_iface.lpVtbl = &vt_INameSpaceTreeControlEvents;
2060 eb->IInputObject_iface.lpVtbl = &vt_IInputObject;
2062 /* Default settings */
2063 eb->navpane.width = 150;
2064 eb->navpane.show = TRUE;
2066 list_init(&eb->event_clients);
2067 list_init(&eb->travellog);
2069 ret = IExplorerBrowser_QueryInterface((IExplorerBrowser*)eb, riid, ppv);
2070 IExplorerBrowser_Release((IExplorerBrowser*)eb);
2072 TRACE("--(%p)\n", ppv);
2073 return ret;