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;
45 } ExplorerBrowserImpl;
47 /**************************************************************************
48 * Main window related functions.
50 static LRESULT main_on_wm_create(HWND hWnd, CREATESTRUCTW *crs)
52 ExplorerBrowserImpl *This = crs->lpCreateParams;
55 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
56 This->hwnd_main = hWnd;
61 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
65 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
66 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
72 /**************************************************************************
73 * IExplorerBrowser Implementation
75 static HRESULT WINAPI IExplorerBrowser_fnQueryInterface(IExplorerBrowser *iface,
76 REFIID riid, void **ppvObject)
78 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
79 TRACE("%p (%s, %p)\n", This, shdebugstr_guid(riid), ppvObject);
82 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
83 IsEqualIID(riid, &IID_IUnknown))
87 else if(IsEqualIID(riid, &IID_IShellBrowser))
89 *ppvObject = &This->lpsbVtbl;
94 IUnknown_AddRef((IUnknown*)*ppvObject);
101 static ULONG WINAPI IExplorerBrowser_fnAddRef(IExplorerBrowser *iface)
103 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
104 LONG ref = InterlockedIncrement(&This->ref);
105 TRACE("%p - ref %d\n", This, ref);
110 static ULONG WINAPI IExplorerBrowser_fnRelease(IExplorerBrowser *iface)
112 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
113 LONG ref = InterlockedDecrement(&This->ref);
114 TRACE("%p - ref %d\n", This, ref);
121 IExplorerBrowser_Destroy(iface);
123 HeapFree(GetProcessHeap(), 0, This);
130 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
131 HWND hwndParent, const RECT *prc,
132 const FOLDERSETTINGS *pfs)
134 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
137 static const WCHAR EB_CLASS_NAME[] =
138 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
140 TRACE("%p (%p, %p, %p)\n", This, hwndParent, prc, pfs);
148 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
150 wc.style = CS_HREDRAW | CS_VREDRAW;
151 wc.lpfnWndProc = main_wndproc;
154 wc.hInstance = shell32_hInstance;
156 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
157 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
158 wc.lpszMenuName = NULL;
159 wc.lpszClassName = EB_CLASS_NAME;
161 if (!RegisterClassW(&wc)) return E_FAIL;
164 style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
165 This->hwnd_main = CreateWindowExW(WS_EX_CONTROLPARENT, EB_CLASS_NAME, NULL, style,
167 prc->right - prc->left, prc->bottom - prc->top,
168 hwndParent, 0, shell32_hInstance, This);
172 ERR("Failed to create the window.\n");
179 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
181 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
184 DestroyWindow(This->hwnd_main);
185 This->destroyed = TRUE;
190 static HRESULT WINAPI IExplorerBrowser_fnSetRect(IExplorerBrowser *iface,
191 HDWP *phdwp, RECT rcBrowser)
193 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
194 FIXME("stub, %p (%p, %s)\n", This, phdwp, wine_dbgstr_rect(&rcBrowser));
199 static HRESULT WINAPI IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser *iface,
200 LPCWSTR pszPropertyBag)
202 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
203 FIXME("stub, %p (%s)\n", This, debugstr_w(pszPropertyBag));
208 static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
209 LPCWSTR pszEmptyText)
211 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
212 FIXME("stub, %p (%s)\n", This, debugstr_w(pszEmptyText));
217 static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
218 const FOLDERSETTINGS *pfs)
220 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
221 FIXME("stub, %p (%p)\n", This, pfs);
226 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
227 IExplorerBrowserEvents *psbe,
230 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
231 FIXME("stub, %p (%p, %p)\n", This, psbe, pdwCookie);
236 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
239 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
240 FIXME("stub, %p (0x%x)\n", This, dwCookie);
245 static HRESULT WINAPI IExplorerBrowser_fnSetOptions(IExplorerBrowser *iface,
246 EXPLORER_BROWSER_OPTIONS dwFlag)
248 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
249 FIXME("stub, %p (0x%x)\n", This, dwFlag);
254 static HRESULT WINAPI IExplorerBrowser_fnGetOptions(IExplorerBrowser *iface,
255 EXPLORER_BROWSER_OPTIONS *pdwFlag)
257 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
258 FIXME("stub, %p (%p)\n", This, pdwFlag);
263 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
264 PCUIDLIST_RELATIVE pidl,
267 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
268 FIXME("stub, %p (%p, 0x%x)\n", This, pidl, uFlags);
273 static HRESULT WINAPI IExplorerBrowser_fnBrowseToObject(IExplorerBrowser *iface,
274 IUnknown *punk, UINT uFlags)
276 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
277 FIXME("stub, %p (%p, 0x%x)\n", This, punk, uFlags);
282 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
284 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
286 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
287 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
292 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
294 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
295 FIXME("stub, %p\n", This);
300 static HRESULT WINAPI IExplorerBrowser_fnGetCurrentView(IExplorerBrowser *iface,
301 REFIID riid, void **ppv)
303 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
304 FIXME("stub, %p (%s, %p)\n", This, shdebugstr_guid(riid), ppv);
310 static const IExplorerBrowserVtbl vt_IExplorerBrowser =
312 IExplorerBrowser_fnQueryInterface,
313 IExplorerBrowser_fnAddRef,
314 IExplorerBrowser_fnRelease,
315 IExplorerBrowser_fnInitialize,
316 IExplorerBrowser_fnDestroy,
317 IExplorerBrowser_fnSetRect,
318 IExplorerBrowser_fnSetPropertyBag,
319 IExplorerBrowser_fnSetEmptyText,
320 IExplorerBrowser_fnSetFolderSettings,
321 IExplorerBrowser_fnAdvise,
322 IExplorerBrowser_fnUnadvise,
323 IExplorerBrowser_fnSetOptions,
324 IExplorerBrowser_fnGetOptions,
325 IExplorerBrowser_fnBrowseToIDList,
326 IExplorerBrowser_fnBrowseToObject,
327 IExplorerBrowser_fnFillFromObject,
328 IExplorerBrowser_fnRemoveAll,
329 IExplorerBrowser_fnGetCurrentView
332 /**************************************************************************
333 * IShellBrowser Implementation
336 static inline ExplorerBrowserImpl *impl_from_IShellBrowser(IShellBrowser *iface)
338 return (ExplorerBrowserImpl *)((char*)iface - FIELD_OFFSET(ExplorerBrowserImpl, lpsbVtbl));
341 static HRESULT WINAPI IShellBrowser_fnQueryInterface(IShellBrowser *iface,
342 REFIID riid, void **ppvObject)
344 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
346 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
349 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
351 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
353 return IUnknown_AddRef((IUnknown*) This);
356 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
358 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
360 return IUnknown_Release((IUnknown*) This);
363 static HRESULT WINAPI IShellBrowser_fnGetWindow(IShellBrowser *iface, HWND *phwnd)
365 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
366 TRACE("%p (%p)\n", This, phwnd);
371 *phwnd = This->hwnd_main;
375 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
378 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
379 FIXME("stub, %p (%d)\n", This, fEnterMode);
384 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
386 LPOLEMENUGROUPWIDTHS lpMenuWidths)
388 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
389 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
391 /* Not implemented. */
395 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
397 HOLEMENU holemenuReserved,
398 HWND hwndActiveObject)
400 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
401 TRACE("%p (%p, %p, %p)\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
403 /* Not implemented. */
407 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
410 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
411 TRACE("%p (%p)\n", This, hmenuShared);
413 /* Not implemented. */
417 static HRESULT WINAPI IShellBrowser_fnSetStatusTextSB(IShellBrowser *iface,
418 LPCOLESTR pszStatusText)
420 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
421 FIXME("stub, %p (%s)\n", This, debugstr_w(pszStatusText));
426 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
429 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
430 FIXME("stub, %p (%d)\n", This, fEnable);
435 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
438 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
439 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
444 static HRESULT WINAPI IShellBrowser_fnBrowseObject(IShellBrowser *iface,
445 LPCITEMIDLIST pidl, UINT wFlags)
447 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
448 FIXME("stub, %p\n", This);
453 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
457 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
458 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
464 static HRESULT WINAPI IShellBrowser_fnGetControlWindow(IShellBrowser *iface,
465 UINT id, HWND *phwnd)
467 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
468 TRACE("%p (%d, %p)\n", This, id, phwnd);
470 /* Not implemented. */
474 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
476 WPARAM wParam, LPARAM lParam,
479 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
480 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
485 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
488 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
489 FIXME("stub, %p (%p)\n", This, ppshv);
494 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
497 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
498 FIXME("stub, %p (%p)\n", This, pshv);
503 static HRESULT WINAPI IShellBrowser_fnSetToolbarItems(IShellBrowser *iface,
504 LPTBBUTTONSB lpButtons,
505 UINT nButtons, UINT uFlags)
507 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
508 FIXME("stub, %p (%p, %d, 0x%x)\n", This, lpButtons, nButtons, uFlags);
513 static const IShellBrowserVtbl vt_IShellBrowser = {
514 IShellBrowser_fnQueryInterface,
515 IShellBrowser_fnAddRef,
516 IShellBrowser_fnRelease,
517 IShellBrowser_fnGetWindow,
518 IShellBrowser_fnContextSensitiveHelp,
519 IShellBrowser_fnInsertMenusSB,
520 IShellBrowser_fnSetMenuSB,
521 IShellBrowser_fnRemoveMenusSB,
522 IShellBrowser_fnSetStatusTextSB,
523 IShellBrowser_fnEnableModelessSB,
524 IShellBrowser_fnTranslateAcceleratorSB,
525 IShellBrowser_fnBrowseObject,
526 IShellBrowser_fnGetViewStateStream,
527 IShellBrowser_fnGetControlWindow,
528 IShellBrowser_fnSendControlMsg,
529 IShellBrowser_fnQueryActiveShellView,
530 IShellBrowser_fnOnViewWindowActive,
531 IShellBrowser_fnSetToolbarItems
534 HRESULT WINAPI ExplorerBrowser_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
536 ExplorerBrowserImpl *eb;
539 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
544 return CLASS_E_NOAGGREGATION;
546 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
548 eb->lpVtbl = &vt_IExplorerBrowser;
549 eb->lpsbVtbl = &vt_IShellBrowser;
551 ret = IExplorerBrowser_QueryInterface((IExplorerBrowser*)eb, riid, ppv);
552 IExplorerBrowser_Release((IExplorerBrowser*)eb);
554 TRACE("--(%p)\n", ppv);