2 * ExplorerBrowser Control implementation.
4 * Copyright 2010 David Hedberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
31 #include "wine/debug.h"
34 #include "shell32_main.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(shell);
38 typedef struct _ExplorerBrowserImpl {
39 const IExplorerBrowserVtbl *lpVtbl;
40 const IShellBrowserVtbl *lpsbVtbl;
47 EXPLORER_BROWSER_OPTIONS eb_options;
52 } ExplorerBrowserImpl;
54 /**************************************************************************
57 static void update_layout(ExplorerBrowserImpl *This)
62 GetClientRect(This->hwnd_main, &rc);
63 CopyRect(&This->sv_rc, &rc);
66 static void size_panes(ExplorerBrowserImpl *This)
68 MoveWindow(This->hwnd_sv,
69 This->sv_rc.left, This->sv_rc.top,
70 This->sv_rc.right - This->sv_rc.left, This->sv_rc.bottom - This->sv_rc.top,
74 static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
82 hr = IShellView_QueryInterface(This->psv, &IID_IFolderView, (void*)&pfv);
85 hr = IFolderView_SetCurrentViewMode(pfv, This->fs.ViewMode);
86 IFolderView_Release(pfv);
92 /**************************************************************************
93 * Main window related functions.
95 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
97 ExplorerBrowserImpl *This = crs->lpCreateParams;
100 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
101 This->hwnd_main = hWnd;
106 static LRESULT main_on_wm_size(ExplorerBrowserImpl *This)
114 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
116 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
120 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
121 case WM_SIZE: return main_on_wm_size(This);
122 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
128 /**************************************************************************
129 * IExplorerBrowser Implementation
131 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
132 REFIID riid, void **ppvObject)
134 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
135 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
138 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
139 IsEqualIID(riid, &IID_IUnknown))
143 else if(IsEqualIID(riid, &IID_IShellBrowser))
145 *ppvObject = &This->lpsbVtbl;
150 IUnknown_AddRef((IUnknown*)*ppvObject);
154 return E_NOINTERFACE;
157 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
159 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
160 LONG ref = InterlockedIncrement(&This->ref);
161 TRACE("%p - ref %d\n", This, ref);
166 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
168 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
169 LONG ref = InterlockedDecrement(&This->ref);
170 TRACE("%p - ref %d\n", This, ref);
177 IExplorerBrowser_Destroy(iface);
179 HeapFree(GetProcessHeap(), 0, This);
186 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
187 HWND hwndParent, const RECT *prc,
188 const FOLDERSETTINGS *pfs)
190 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
193 static const WCHAR EB_CLASS_NAME[] =
194 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
196 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
204 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
206 wc.style = CS_HREDRAW | CS_VREDRAW;
207 wc.lpfnWndProc = main_wndproc;
210 wc.hInstance = shell32_hInstance;
212 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
213 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
214 wc.lpszMenuName = NULL;
215 wc.lpszClassName = EB_CLASS_NAME;
217 if (!RegisterClassW(&wc)) return E_FAIL;
220 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
221 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
223 prc->right - prc->left, prc->bottom - prc->top,
224 hwndParent, 0, shell32_hInstance, This);
228 ERR("Failed to create the window.\n");
232 This->fs.ViewMode = pfs ? pfs->ViewMode : FVM_DETAILS;
233 This->fs.fFlags = pfs ? (pfs->fFlags | FWF_NOCLIENTEDGE) : FWF_NOCLIENTEDGE;
238 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
240 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
245 IShellView_DestroyViewWindow(This->psv);
246 IShellView_Release(This->psv);
248 This->hwnd_sv = NULL;
251 DestroyWindow(This->hwnd_main);
252 This->destroyed = TRUE;
257 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
258 HDWP *phdwp, RECT rcBrowser)
260 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
261 TRACE("%p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
265 *phdwp = DeferWindowPos(*phdwp, This->hwnd_main, NULL, rcBrowser.left, rcBrowser.top,
266 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top,
267 SWP_NOZORDER | SWP_NOACTIVATE);
271 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
272 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
278 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
279 LPCWSTR pszPropertyBag)
281 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
282 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
287 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
288 LPCWSTR pszEmptyText)
290 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
291 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
296 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
297 const FOLDERSETTINGS *pfs)
299 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
300 TRACE("%p (%p)\n", This, pfs);
305 This->fs.ViewMode = pfs->ViewMode;
306 This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
308 /* Change the settings of the current view, if any. */
309 return change_viewmode(This, This->fs.ViewMode);
312 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
313 IExplorerBrowserEvents *psbe,
316 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
317 FIXME("stub, %p (%p, %p)\n", This, psbe, pdwCookie);
322 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
325 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
326 FIXME("stub, %p (0x%x)\n", This, dwCookie);
331 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
332 EXPLORER_BROWSER_OPTIONS dwFlag)
334 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
335 static const EXPLORER_BROWSER_OPTIONS unsupported_options =
336 EBO_SHOWFRAMES | EBO_ALWAYSNAVIGATE | EBO_NOWRAPPERWINDOW | EBO_HTMLSHAREPOINTVIEW;
338 TRACE("%p (0x%x)\n", This, dwFlag);
340 if(dwFlag & unsupported_options)
341 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag);
343 This->eb_options = dwFlag;
348 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
349 EXPLORER_BROWSER_OPTIONS *pdwFlag)
351 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
352 TRACE("%p (%p)\n", This, pdwFlag);
354 *pdwFlag = This->eb_options;
359 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
360 PCUIDLIST_RELATIVE pidl,
363 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
364 FIXME("stub, %p (%p, 0x%x)\n", This, pidl, uFlags);
369 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
370 IUnknown *punk, UINT uFlags)
372 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
373 FIXME("stub, %p (%p, 0x%x)\n", This, punk, uFlags);
378 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
380 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
382 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
383 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
388 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
390 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
391 FIXME("stub, %p\n", This);
396 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
397 REFIID riid, void **ppv)
399 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
400 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
405 return IShellView_QueryInterface(This->psv, riid, ppv);
408 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
410 IExplorerBrowser_fnQueryInterface,
411 IExplorerBrowser_fnAddRef,
412 IExplorerBrowser_fnRelease,
413 IExplorerBrowser_fnInitialize,
414 IExplorerBrowser_fnDestroy,
415 IExplorerBrowser_fnSetRect,
416 IExplorerBrowser_fnSetPropertyBag,
417 IExplorerBrowser_fnSetEmptyText,
418 IExplorerBrowser_fnSetFolderSettings,
419 IExplorerBrowser_fnAdvise,
420 IExplorerBrowser_fnUnadvise,
421 IExplorerBrowser_fnSetOptions,
422 IExplorerBrowser_fnGetOptions,
423 IExplorerBrowser_fnBrowseToIDList,
424 IExplorerBrowser_fnBrowseToObject,
425 IExplorerBrowser_fnFillFromObject,
426 IExplorerBrowser_fnRemoveAll,
427 IExplorerBrowser_fnGetCurrentView
430 /**************************************************************************
431 * IShellBrowser Implementation
434 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
436 return (ExplorerBrowserImpl *)((char*)iface - FIELD_OFFSET(ExplorerBrowserImpl, lpsbVtbl));
439 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
440 REFIID riid, void **ppvObject)
442 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
444 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
447 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
449 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
451 return IUnknown_AddRef((IUnknown*) This);
454 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
456 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
458 return IUnknown_Release((IUnknown*) This);
461 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
463 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
464 TRACE("%p (%p)\n", This, phwnd);
469 *phwnd = This->hwnd_main;
473 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
476 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
477 FIXME("stub, %p (%d)\n", This, fEnterMode);
482 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
484 LPOLEMENUGROUPWIDTHS lpMenuWidths)
486 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
487 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
489 /* Not implemented. */
493 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
495 HOLEMENU holemenuReserved,
496 HWND hwndActiveObject)
498 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
499 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
501 /* Not implemented. */
505 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
508 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
509 TRACE("%p (%p)\n", This, hmenuShared);
511 /* Not implemented. */
515 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
516 LPCOLESTR pszStatusText)
518 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
519 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
524 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
527 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
528 FIXME("stub, %p (%d)\n", This, fEnable);
533 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
536 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
537 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
542 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
543 LPCITEMIDLIST pidl, UINT wFlags)
545 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
546 FIXME("stub, %p\n", This);
551 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
555 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
556 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
562 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
563 UINT id, HWND *phwnd)
565 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
566 TRACE("%p (%d, %p)\n", This, id, phwnd);
568 /* Not implemented. */
572 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
574 WPARAM wParam, LPARAM lParam,
577 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
578 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
583 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
586 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
587 TRACE("%p (%p)\n", This, ppshv);
593 IShellView_AddRef(This->psv);
598 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
601 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
602 FIXME("stub, %p (%p)\n", This, pshv);
607 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
608 LPTBBUTTONSB lpButtons,
609 UINT nButtons, UINT uFlags)
611 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
612 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
617 static const IShellBrowserVtbl vt_IShellBrowser = {
618 IShellBrowser_fnQueryInterface,
619 IShellBrowser_fnAddRef,
620 IShellBrowser_fnRelease,
621 IShellBrowser_fnGetWindow,
622 IShellBrowser_fnContextSensitiveHelp,
623 IShellBrowser_fnInsertMenusSB,
624 IShellBrowser_fnSetMenuSB,
625 IShellBrowser_fnRemoveMenusSB,
626 IShellBrowser_fnSetStatusTextSB,
627 IShellBrowser_fnEnableModelessSB,
628 IShellBrowser_fnTranslateAcceleratorSB,
629 IShellBrowser_fnBrowseObject,
630 IShellBrowser_fnGetViewStateStream,
631 IShellBrowser_fnGetControlWindow,
632 IShellBrowser_fnSendControlMsg,
633 IShellBrowser_fnQueryActiveShellView,
634 IShellBrowser_fnOnViewWindowActive,
635 IShellBrowser_fnSetToolbarItems
638 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
640 ExplorerBrowserImpl *eb;
643 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
648 return CLASS_E_NOAGGREGATION;
650 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
652 eb->lpVtbl = &vt_IExplorerBrowser;
653 eb->lpsbVtbl = &vt_IShellBrowser;
655 ret = IExplorerBrowser_QueryInterface((IExplorerBrowser*)eb, riid, ppv);
656 IExplorerBrowser_Release((IExplorerBrowser*)eb);
658 TRACE("--(%p)\n", ppv);