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
;
46 EXPLORER_BROWSER_OPTIONS eb_options
;
47 } ExplorerBrowserImpl
;
49 /**************************************************************************
50 * Main window related functions.
52 static LRESULT
main_on_wm_create(HWND hWnd
, CREATESTRUCTW
*crs
)
54 ExplorerBrowserImpl
*This
= crs
->lpCreateParams
;
57 SetWindowLongPtrW(hWnd
, GWLP_USERDATA
, (LPARAM
)This
);
58 This
->hwnd_main
= hWnd
;
63 static LRESULT CALLBACK
main_wndproc(HWND hWnd
, UINT uMessage
, WPARAM wParam
, LPARAM lParam
)
67 case WM_CREATE
: return main_on_wm_create(hWnd
, (CREATESTRUCTW
*)lParam
);
68 default: return DefWindowProcW(hWnd
, uMessage
, wParam
, lParam
);
74 /**************************************************************************
75 * IExplorerBrowser Implementation
77 static HRESULT WINAPI
IExplorerBrowser_fnQueryInterface(IExplorerBrowser
*iface
,
78 REFIID riid
, void **ppvObject
)
80 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
81 TRACE("%p (%s, %p)\n", This
, shdebugstr_guid(riid
), ppvObject
);
84 if(IsEqualIID(riid
, &IID_IExplorerBrowser
) ||
85 IsEqualIID(riid
, &IID_IUnknown
))
89 else if(IsEqualIID(riid
, &IID_IShellBrowser
))
91 *ppvObject
= &This
->lpsbVtbl
;
96 IUnknown_AddRef((IUnknown
*)*ppvObject
);
100 return E_NOINTERFACE
;
103 static ULONG WINAPI
IExplorerBrowser_fnAddRef(IExplorerBrowser
*iface
)
105 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
106 LONG ref
= InterlockedIncrement(&This
->ref
);
107 TRACE("%p - ref %d\n", This
, ref
);
112 static ULONG WINAPI
IExplorerBrowser_fnRelease(IExplorerBrowser
*iface
)
114 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
115 LONG ref
= InterlockedDecrement(&This
->ref
);
116 TRACE("%p - ref %d\n", This
, ref
);
123 IExplorerBrowser_Destroy(iface
);
125 HeapFree(GetProcessHeap(), 0, This
);
132 static HRESULT WINAPI
IExplorerBrowser_fnInitialize(IExplorerBrowser
*iface
,
133 HWND hwndParent
, const RECT
*prc
,
134 const FOLDERSETTINGS
*pfs
)
136 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
139 static const WCHAR EB_CLASS_NAME
[] =
140 {'E','x','p','l','o','r','e','r','B','r','o','w','s','e','r','C','o','n','t','r','o','l',0};
142 TRACE("%p (%p, %p, %p)\n", This
, hwndParent
, prc
, pfs
);
150 if( !GetClassInfoW(shell32_hInstance
, EB_CLASS_NAME
, &wc
) )
152 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
153 wc
.lpfnWndProc
= main_wndproc
;
156 wc
.hInstance
= shell32_hInstance
;
158 wc
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
159 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
160 wc
.lpszMenuName
= NULL
;
161 wc
.lpszClassName
= EB_CLASS_NAME
;
163 if (!RegisterClassW(&wc
)) return E_FAIL
;
166 style
= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
;
167 This
->hwnd_main
= CreateWindowExW(WS_EX_CONTROLPARENT
, EB_CLASS_NAME
, NULL
, style
,
169 prc
->right
- prc
->left
, prc
->bottom
- prc
->top
,
170 hwndParent
, 0, shell32_hInstance
, This
);
174 ERR("Failed to create the window.\n");
181 static HRESULT WINAPI
IExplorerBrowser_fnDestroy(IExplorerBrowser
*iface
)
183 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
186 DestroyWindow(This
->hwnd_main
);
187 This
->destroyed
= TRUE
;
192 static HRESULT WINAPI
IExplorerBrowser_fnSetRect(IExplorerBrowser
*iface
,
193 HDWP
*phdwp
, RECT rcBrowser
)
195 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
196 TRACE("%p (%p, %s)\n", This
, phdwp
, wine_dbgstr_rect(&rcBrowser
));
200 *phdwp
= DeferWindowPos(*phdwp
, This
->hwnd_main
, NULL
, rcBrowser
.left
, rcBrowser
.top
,
201 rcBrowser
.right
- rcBrowser
.left
, rcBrowser
.bottom
- rcBrowser
.top
,
202 SWP_NOZORDER
| SWP_NOACTIVATE
);
206 MoveWindow(This
->hwnd_main
, rcBrowser
.left
, rcBrowser
.top
,
207 rcBrowser
.right
- rcBrowser
.left
, rcBrowser
.bottom
- rcBrowser
.top
, TRUE
);
213 static HRESULT WINAPI
IExplorerBrowser_fnSetPropertyBag(IExplorerBrowser
*iface
,
214 LPCWSTR pszPropertyBag
)
216 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
217 FIXME("stub, %p (%s)\n", This
, debugstr_w(pszPropertyBag
));
222 static HRESULT WINAPI
IExplorerBrowser_fnSetEmptyText(IExplorerBrowser
*iface
,
223 LPCWSTR pszEmptyText
)
225 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
226 FIXME("stub, %p (%s)\n", This
, debugstr_w(pszEmptyText
));
231 static HRESULT WINAPI
IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser
*iface
,
232 const FOLDERSETTINGS
*pfs
)
234 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
235 FIXME("stub, %p (%p)\n", This
, pfs
);
240 static HRESULT WINAPI
IExplorerBrowser_fnAdvise(IExplorerBrowser
*iface
,
241 IExplorerBrowserEvents
*psbe
,
244 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
245 FIXME("stub, %p (%p, %p)\n", This
, psbe
, pdwCookie
);
250 static HRESULT WINAPI
IExplorerBrowser_fnUnadvise(IExplorerBrowser
*iface
,
253 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
254 FIXME("stub, %p (0x%x)\n", This
, dwCookie
);
259 static HRESULT WINAPI
IExplorerBrowser_fnSetOptions(IExplorerBrowser
*iface
,
260 EXPLORER_BROWSER_OPTIONS dwFlag
)
262 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
263 static const EXPLORER_BROWSER_OPTIONS unsupported_options
=
264 EBO_SHOWFRAMES
| EBO_ALWAYSNAVIGATE
| EBO_NOWRAPPERWINDOW
| EBO_HTMLSHAREPOINTVIEW
;
266 TRACE("%p (0x%x)\n", This
, dwFlag
);
268 if(dwFlag
& unsupported_options
)
269 FIXME("Flags 0x%08x contains unsupported options.\n", dwFlag
);
271 This
->eb_options
= dwFlag
;
276 static HRESULT WINAPI
IExplorerBrowser_fnGetOptions(IExplorerBrowser
*iface
,
277 EXPLORER_BROWSER_OPTIONS
*pdwFlag
)
279 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
280 TRACE("%p (%p)\n", This
, pdwFlag
);
282 *pdwFlag
= This
->eb_options
;
287 static HRESULT WINAPI
IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser
*iface
,
288 PCUIDLIST_RELATIVE pidl
,
291 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
292 FIXME("stub, %p (%p, 0x%x)\n", This
, pidl
, uFlags
);
297 static HRESULT WINAPI
IExplorerBrowser_fnBrowseToObject(IExplorerBrowser
*iface
,
298 IUnknown
*punk
, UINT uFlags
)
300 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
301 FIXME("stub, %p (%p, 0x%x)\n", This
, punk
, uFlags
);
306 static HRESULT WINAPI
IExplorerBrowser_fnFillFromObject(IExplorerBrowser
*iface
,
308 EXPLORER_BROWSER_FILL_FLAGS dwFlags
)
310 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
311 FIXME("stub, %p (%p, 0x%x)\n", This
, punk
, dwFlags
);
316 static HRESULT WINAPI
IExplorerBrowser_fnRemoveAll(IExplorerBrowser
*iface
)
318 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
319 FIXME("stub, %p\n", This
);
324 static HRESULT WINAPI
IExplorerBrowser_fnGetCurrentView(IExplorerBrowser
*iface
,
325 REFIID riid
, void **ppv
)
327 ExplorerBrowserImpl
*This
= (ExplorerBrowserImpl
*)iface
;
328 FIXME("stub, %p (%s, %p)\n", This
, shdebugstr_guid(riid
), ppv
);
334 static const IExplorerBrowserVtbl vt_IExplorerBrowser
=
336 IExplorerBrowser_fnQueryInterface
,
337 IExplorerBrowser_fnAddRef
,
338 IExplorerBrowser_fnRelease
,
339 IExplorerBrowser_fnInitialize
,
340 IExplorerBrowser_fnDestroy
,
341 IExplorerBrowser_fnSetRect
,
342 IExplorerBrowser_fnSetPropertyBag
,
343 IExplorerBrowser_fnSetEmptyText
,
344 IExplorerBrowser_fnSetFolderSettings
,
345 IExplorerBrowser_fnAdvise
,
346 IExplorerBrowser_fnUnadvise
,
347 IExplorerBrowser_fnSetOptions
,
348 IExplorerBrowser_fnGetOptions
,
349 IExplorerBrowser_fnBrowseToIDList
,
350 IExplorerBrowser_fnBrowseToObject
,
351 IExplorerBrowser_fnFillFromObject
,
352 IExplorerBrowser_fnRemoveAll
,
353 IExplorerBrowser_fnGetCurrentView
356 /**************************************************************************
357 * IShellBrowser Implementation
360 static inline ExplorerBrowserImpl
*impl_from_IShellBrowser(IShellBrowser
*iface
)
362 return (ExplorerBrowserImpl
*)((char*)iface
- FIELD_OFFSET(ExplorerBrowserImpl
, lpsbVtbl
));
365 static HRESULT WINAPI
IShellBrowser_fnQueryInterface(IShellBrowser
*iface
,
366 REFIID riid
, void **ppvObject
)
368 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
370 return IUnknown_QueryInterface((IUnknown
*) This
, riid
, ppvObject
);
373 static ULONG WINAPI
IShellBrowser_fnAddRef(IShellBrowser
*iface
)
375 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
377 return IUnknown_AddRef((IUnknown
*) This
);
380 static ULONG WINAPI
IShellBrowser_fnRelease(IShellBrowser
*iface
)
382 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
384 return IUnknown_Release((IUnknown
*) This
);
387 static HRESULT WINAPI
IShellBrowser_fnGetWindow(IShellBrowser
*iface
, HWND
*phwnd
)
389 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
390 TRACE("%p (%p)\n", This
, phwnd
);
395 *phwnd
= This
->hwnd_main
;
399 static HRESULT WINAPI
IShellBrowser_fnContextSensitiveHelp(IShellBrowser
*iface
,
402 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
403 FIXME("stub, %p (%d)\n", This
, fEnterMode
);
408 static HRESULT WINAPI
IShellBrowser_fnInsertMenusSB(IShellBrowser
*iface
,
410 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
412 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
413 TRACE("%p (%p, %p)\n", This
, hmenuShared
, lpMenuWidths
);
415 /* Not implemented. */
419 static HRESULT WINAPI
IShellBrowser_fnSetMenuSB(IShellBrowser
*iface
,
421 HOLEMENU holemenuReserved
,
422 HWND hwndActiveObject
)
424 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
425 TRACE("%p (%p, %p, %p)\n", This
, hmenuShared
, holemenuReserved
, hwndActiveObject
);
427 /* Not implemented. */
431 static HRESULT WINAPI
IShellBrowser_fnRemoveMenusSB(IShellBrowser
*iface
,
434 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
435 TRACE("%p (%p)\n", This
, hmenuShared
);
437 /* Not implemented. */
441 static HRESULT WINAPI
IShellBrowser_fnSetStatusTextSB(IShellBrowser
*iface
,
442 LPCOLESTR pszStatusText
)
444 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
445 FIXME("stub, %p (%s)\n", This
, debugstr_w(pszStatusText
));
450 static HRESULT WINAPI
IShellBrowser_fnEnableModelessSB(IShellBrowser
*iface
,
453 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
454 FIXME("stub, %p (%d)\n", This
, fEnable
);
459 static HRESULT WINAPI
IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser
*iface
,
462 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
463 FIXME("stub, %p (%p, 0x%x)\n", This
, pmsg
, wID
);
468 static HRESULT WINAPI
IShellBrowser_fnBrowseObject(IShellBrowser
*iface
,
469 LPCITEMIDLIST pidl
, UINT wFlags
)
471 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
472 FIXME("stub, %p\n", This
);
477 static HRESULT WINAPI
IShellBrowser_fnGetViewStateStream(IShellBrowser
*iface
,
481 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
482 FIXME("stub, %p (0x%x, %p)\n", This
, grfMode
, ppStrm
);
488 static HRESULT WINAPI
IShellBrowser_fnGetControlWindow(IShellBrowser
*iface
,
489 UINT id
, HWND
*phwnd
)
491 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
492 TRACE("%p (%d, %p)\n", This
, id
, phwnd
);
494 /* Not implemented. */
498 static HRESULT WINAPI
IShellBrowser_fnSendControlMsg(IShellBrowser
*iface
,
500 WPARAM wParam
, LPARAM lParam
,
503 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
504 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This
, id
, uMsg
, wParam
, lParam
, pret
);
509 static HRESULT WINAPI
IShellBrowser_fnQueryActiveShellView(IShellBrowser
*iface
,
512 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
513 FIXME("stub, %p (%p)\n", This
, ppshv
);
518 static HRESULT WINAPI
IShellBrowser_fnOnViewWindowActive(IShellBrowser
*iface
,
521 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
522 FIXME("stub, %p (%p)\n", This
, pshv
);
527 static HRESULT WINAPI
IShellBrowser_fnSetToolbarItems(IShellBrowser
*iface
,
528 LPTBBUTTONSB lpButtons
,
529 UINT nButtons
, UINT uFlags
)
531 ExplorerBrowserImpl
*This
= impl_from_IShellBrowser(iface
);
532 FIXME("stub, %p (%p, %d, 0x%x)\n", This
, lpButtons
, nButtons
, uFlags
);
537 static const IShellBrowserVtbl vt_IShellBrowser
= {
538 IShellBrowser_fnQueryInterface
,
539 IShellBrowser_fnAddRef
,
540 IShellBrowser_fnRelease
,
541 IShellBrowser_fnGetWindow
,
542 IShellBrowser_fnContextSensitiveHelp
,
543 IShellBrowser_fnInsertMenusSB
,
544 IShellBrowser_fnSetMenuSB
,
545 IShellBrowser_fnRemoveMenusSB
,
546 IShellBrowser_fnSetStatusTextSB
,
547 IShellBrowser_fnEnableModelessSB
,
548 IShellBrowser_fnTranslateAcceleratorSB
,
549 IShellBrowser_fnBrowseObject
,
550 IShellBrowser_fnGetViewStateStream
,
551 IShellBrowser_fnGetControlWindow
,
552 IShellBrowser_fnSendControlMsg
,
553 IShellBrowser_fnQueryActiveShellView
,
554 IShellBrowser_fnOnViewWindowActive
,
555 IShellBrowser_fnSetToolbarItems
558 HRESULT WINAPI
ExplorerBrowser_Constructor(IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
560 ExplorerBrowserImpl
*eb
;
563 TRACE("%p %s %p\n", pUnkOuter
, shdebugstr_guid (riid
), ppv
);
568 return CLASS_E_NOAGGREGATION
;
570 eb
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(ExplorerBrowserImpl
));
572 eb
->lpVtbl
= &vt_IExplorerBrowser
;
573 eb
->lpsbVtbl
= &vt_IShellBrowser
;
575 ret
= IExplorerBrowser_QueryInterface((IExplorerBrowser
*)eb
, riid
, ppv
);
576 IExplorerBrowser_Release((IExplorerBrowser
*)eb
);
578 TRACE("--(%p)\n", ppv
);