shell32: Implement IExplorerBrowser::SetOptions and IExplorerBrowser::GetOptions.
[wine/multimedia.git] / dlls / shell32 / ebrowser.c
blob20b5363014a517f476d39e8205ea27f2dfea81e3
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/debug.h"
32 #include "debughlp.h"
34 #include "shell32_main.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(shell);
38 typedef struct _ExplorerBrowserImpl {
39 const IExplorerBrowserVtbl *lpVtbl;
40 const IShellBrowserVtbl *lpsbVtbl;
41 LONG ref;
42 BOOL destroyed;
44 HWND hwnd_main;
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;
55 TRACE("%p\n", This);
57 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
58 This->hwnd_main = hWnd;
60 return TRUE;
63 static LRESULT CALLBACK main_wndproc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
65 switch(uMessage)
67 case WM_CREATE: return main_on_wm_create(hWnd, (CREATESTRUCTW*)lParam);
68 default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
71 return 0;
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);
83 *ppvObject = NULL;
84 if(IsEqualIID(riid, &IID_IExplorerBrowser) ||
85 IsEqualIID(riid, &IID_IUnknown))
87 *ppvObject = This;
89 else if(IsEqualIID(riid, &IID_IShellBrowser))
91 *ppvObject = &This->lpsbVtbl;
94 if(*ppvObject)
96 IUnknown_AddRef((IUnknown*)*ppvObject);
97 return S_OK;
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);
109 return 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);
118 if(!ref)
120 TRACE("Freeing.\n");
122 if(!This->destroyed)
123 IExplorerBrowser_Destroy(iface);
125 HeapFree(GetProcessHeap(), 0, This);
126 return 0;
129 return ref;
132 static HRESULT WINAPI IExplorerBrowser_fnInitialize(IExplorerBrowser *iface,
133 HWND hwndParent, const RECT *prc,
134 const FOLDERSETTINGS *pfs)
136 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
137 WNDCLASSW wc;
138 LONG style;
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);
144 if(This->hwnd_main)
145 return E_UNEXPECTED;
147 if(!hwndParent)
148 return E_INVALIDARG;
150 if( !GetClassInfoW(shell32_hInstance, EB_CLASS_NAME, &wc) )
152 wc.style = CS_HREDRAW | CS_VREDRAW;
153 wc.lpfnWndProc = main_wndproc;
154 wc.cbClsExtra = 0;
155 wc.cbWndExtra = 0;
156 wc.hInstance = shell32_hInstance;
157 wc.hIcon = 0;
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,
168 prc->left, prc->top,
169 prc->right - prc->left, prc->bottom - prc->top,
170 hwndParent, 0, shell32_hInstance, This);
172 if(!This->hwnd_main)
174 ERR("Failed to create the window.\n");
175 return E_FAIL;
178 return S_OK;
181 static HRESULT WINAPI IExplorerBrowser_fnDestroy(IExplorerBrowser *iface)
183 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
184 TRACE("%p\n", This);
186 DestroyWindow(This->hwnd_main);
187 This->destroyed = TRUE;
189 return S_OK;
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));
198 if(phdwp)
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);
204 else
206 MoveWindow(This->hwnd_main, rcBrowser.left, rcBrowser.top,
207 rcBrowser.right - rcBrowser.left, rcBrowser.bottom - rcBrowser.top, TRUE);
210 return S_OK;
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));
219 return E_NOTIMPL;
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));
228 return E_NOTIMPL;
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);
237 return E_NOTIMPL;
240 static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
241 IExplorerBrowserEvents *psbe,
242 DWORD *pdwCookie)
244 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
245 FIXME("stub, %p (%p, %p)\n", This, psbe, pdwCookie);
247 return E_NOTIMPL;
250 static HRESULT WINAPI IExplorerBrowser_fnUnadvise(IExplorerBrowser *iface,
251 DWORD dwCookie)
253 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
254 FIXME("stub, %p (0x%x)\n", This, dwCookie);
256 return E_NOTIMPL;
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;
273 return S_OK;
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;
284 return S_OK;
287 static HRESULT WINAPI IExplorerBrowser_fnBrowseToIDList(IExplorerBrowser *iface,
288 PCUIDLIST_RELATIVE pidl,
289 UINT uFlags)
291 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
292 FIXME("stub, %p (%p, 0x%x)\n", This, pidl, uFlags);
294 return E_NOTIMPL;
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);
303 return E_NOTIMPL;
306 static HRESULT WINAPI IExplorerBrowser_fnFillFromObject(IExplorerBrowser *iface,
307 IUnknown *punk,
308 EXPLORER_BROWSER_FILL_FLAGS dwFlags)
310 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
311 FIXME("stub, %p (%p, 0x%x)\n", This, punk, dwFlags);
313 return E_NOTIMPL;
316 static HRESULT WINAPI IExplorerBrowser_fnRemoveAll(IExplorerBrowser *iface)
318 ExplorerBrowserImpl *This = (ExplorerBrowserImpl*)iface;
319 FIXME("stub, %p\n", This);
321 return E_NOTIMPL;
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);
330 *ppv = NULL;
331 return E_FAIL;
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);
369 TRACE("%p\n", This);
370 return IUnknown_QueryInterface((IUnknown*) This, riid, ppvObject);
373 static ULONG WINAPI IShellBrowser_fnAddRef(IShellBrowser *iface)
375 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
376 TRACE("%p\n", This);
377 return IUnknown_AddRef((IUnknown*) This);
380 static ULONG WINAPI IShellBrowser_fnRelease(IShellBrowser *iface)
382 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
383 TRACE("%p\n", This);
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);
392 if(!This->hwnd_main)
393 return E_FAIL;
395 *phwnd = This->hwnd_main;
396 return S_OK;
399 static HRESULT WINAPI IShellBrowser_fnContextSensitiveHelp(IShellBrowser *iface,
400 BOOL fEnterMode)
402 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
403 FIXME("stub, %p (%d)\n", This, fEnterMode);
405 return E_NOTIMPL;
408 static HRESULT WINAPI IShellBrowser_fnInsertMenusSB(IShellBrowser *iface,
409 HMENU hmenuShared,
410 LPOLEMENUGROUPWIDTHS lpMenuWidths)
412 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
413 TRACE("%p (%p, %p)\n", This, hmenuShared, lpMenuWidths);
415 /* Not implemented. */
416 return E_NOTIMPL;
419 static HRESULT WINAPI IShellBrowser_fnSetMenuSB(IShellBrowser *iface,
420 HMENU hmenuShared,
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. */
428 return E_NOTIMPL;
431 static HRESULT WINAPI IShellBrowser_fnRemoveMenusSB(IShellBrowser *iface,
432 HMENU hmenuShared)
434 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
435 TRACE("%p (%p)\n", This, hmenuShared);
437 /* Not implemented. */
438 return E_NOTIMPL;
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));
447 return E_NOTIMPL;
450 static HRESULT WINAPI IShellBrowser_fnEnableModelessSB(IShellBrowser *iface,
451 BOOL fEnable)
453 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
454 FIXME("stub, %p (%d)\n", This, fEnable);
456 return E_NOTIMPL;
459 static HRESULT WINAPI IShellBrowser_fnTranslateAcceleratorSB(IShellBrowser *iface,
460 MSG *pmsg, WORD wID)
462 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
463 FIXME("stub, %p (%p, 0x%x)\n", This, pmsg, wID);
465 return E_NOTIMPL;
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);
474 return E_NOTIMPL;
477 static HRESULT WINAPI IShellBrowser_fnGetViewStateStream(IShellBrowser *iface,
478 DWORD grfMode,
479 IStream **ppStrm)
481 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
482 FIXME("stub, %p (0x%x, %p)\n", This, grfMode, ppStrm);
484 *ppStrm = NULL;
485 return E_FAIL;
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. */
495 return E_NOTIMPL;
498 static HRESULT WINAPI IShellBrowser_fnSendControlMsg(IShellBrowser *iface,
499 UINT id, UINT uMsg,
500 WPARAM wParam, LPARAM lParam,
501 LRESULT *pret)
503 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
504 FIXME("stub, %p (%d, %d, %lx, %lx, %p)\n", This, id, uMsg, wParam, lParam, pret);
506 return E_NOTIMPL;
509 static HRESULT WINAPI IShellBrowser_fnQueryActiveShellView(IShellBrowser *iface,
510 IShellView **ppshv)
512 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
513 FIXME("stub, %p (%p)\n", This, ppshv);
515 return E_NOTIMPL;
518 static HRESULT WINAPI IShellBrowser_fnOnViewWindowActive(IShellBrowser *iface,
519 IShellView *pshv)
521 ExplorerBrowserImpl *This = impl_from_IShellBrowser(iface);
522 FIXME("stub, %p (%p)\n", This, pshv);
524 return E_NOTIMPL;
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);
534 return E_NOTIMPL;
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;
561 HRESULT ret;
563 TRACE("%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
565 if(!ppv)
566 return E_POINTER;
567 if(pUnkOuter)
568 return CLASS_E_NOAGGREGATION;
570 eb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ExplorerBrowserImpl));
571 eb->ref = 1;
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);
579 return ret;