dmstyle: Remove an unused function declaration.
[wine/multimedia.git] / dlls / hhctrl.ocx / webbrowser.c
blob90b405d332e4bb7164323935e34b11f70712daca
1 /*
2 * WebBrowser Implementation
4 * Copyright 2005 James Hawkins
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 "hhctrl.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
27 typedef struct IOleClientSiteImpl
29 IOleClientSite IOleClientSite_iface;
30 IOleInPlaceSite IOleInPlaceSite_iface;
31 IOleInPlaceFrame IOleInPlaceFrame_iface;
32 IDocHostUIHandler IDocHostUIHandler_iface;
34 /* IOleClientSiteImpl data */
35 IOleObject *pBrowserObject;
36 LONG ref;
38 /* IOleInPlaceFrame data */
39 HWND hwndWindow;
40 } IOleClientSiteImpl;
42 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
44 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
47 static HRESULT STDMETHODCALLTYPE Site_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppvObj)
49 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
51 *ppvObj = NULL;
53 if (IsEqualIID(riid, &IID_IUnknown)) {
54 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppvObj);
55 *ppvObj = &This->IOleClientSite_iface;
56 }else if(IsEqualIID(riid, &IID_IOleClientSite)) {
57 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppvObj);
58 *ppvObj = &This->IOleClientSite_iface;
59 }else if (IsEqualIID(riid, &IID_IOleInPlaceSite)) {
60 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppvObj);
61 *ppvObj = &This->IOleInPlaceSite_iface;
62 }else if (IsEqualIID(riid, &IID_IOleInPlaceFrame)) {
63 TRACE("(%p)->(IID_IOleInPlaceFrame %p)\n", This, ppvObj);
64 *ppvObj = &This->IOleInPlaceSite_iface;
65 }else if (IsEqualIID(riid, &IID_IDocHostUIHandler)) {
66 TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppvObj);
67 *ppvObj = &This->IDocHostUIHandler_iface;
68 }else {
69 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
70 return E_NOINTERFACE;
73 IUnknown_AddRef((IUnknown*)*ppvObj);
74 return S_OK;
77 static ULONG STDMETHODCALLTYPE Site_AddRef(IOleClientSite *iface)
79 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
80 LONG ref = InterlockedIncrement(&This->ref);
82 TRACE("(%p) ref=%d\n", This, ref);
84 return ref;
87 static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
89 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
90 LONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p) ref=%d\n", This, ref);
94 if(!ref)
95 heap_free(This);
97 return ref;
100 static HRESULT STDMETHODCALLTYPE Site_SaveObject(IOleClientSite *iface)
102 return E_NOTIMPL;
105 static HRESULT STDMETHODCALLTYPE Site_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
107 return E_NOTIMPL;
110 static HRESULT STDMETHODCALLTYPE Site_GetContainer(IOleClientSite *iface, LPOLECONTAINER *ppContainer)
112 *ppContainer = NULL;
114 return E_NOINTERFACE;
117 static HRESULT STDMETHODCALLTYPE Site_ShowObject(IOleClientSite *iface)
119 return NOERROR;
122 static HRESULT STDMETHODCALLTYPE Site_OnShowWindow(IOleClientSite *iface, BOOL fShow)
124 return E_NOTIMPL;
127 static HRESULT STDMETHODCALLTYPE Site_RequestNewObjectLayout(IOleClientSite *iface)
129 return E_NOTIMPL;
132 static const IOleClientSiteVtbl MyIOleClientSiteTable =
134 Site_QueryInterface,
135 Site_AddRef,
136 Site_Release,
137 Site_SaveObject,
138 Site_GetMoniker,
139 Site_GetContainer,
140 Site_ShowObject,
141 Site_OnShowWindow,
142 Site_RequestNewObjectLayout
145 static inline IOleClientSiteImpl *impl_from_IDocHostUIHandler(IDocHostUIHandler *iface)
147 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IDocHostUIHandler_iface);
150 static HRESULT STDMETHODCALLTYPE UI_QueryInterface(IDocHostUIHandler *iface, REFIID riid, LPVOID *ppvObj)
152 IOleClientSiteImpl *This = impl_from_IDocHostUIHandler(iface);
154 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
157 static ULONG STDMETHODCALLTYPE UI_AddRef(IDocHostUIHandler *iface)
159 IOleClientSiteImpl *This = impl_from_IDocHostUIHandler(iface);
161 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
164 static ULONG STDMETHODCALLTYPE UI_Release(IDocHostUIHandler * iface)
166 IOleClientSiteImpl *This = impl_from_IDocHostUIHandler(iface);
168 return IOleClientSite_Release(&This->IOleClientSite_iface);
171 static HRESULT STDMETHODCALLTYPE UI_ShowContextMenu(IDocHostUIHandler *iface, DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
173 return S_OK;
176 static HRESULT STDMETHODCALLTYPE UI_GetHostInfo(IDocHostUIHandler *iface, DOCHOSTUIINFO *pInfo)
178 pInfo->cbSize = sizeof(DOCHOSTUIINFO);
179 pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
180 pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
182 return S_OK;
185 static HRESULT STDMETHODCALLTYPE UI_ShowUI(IDocHostUIHandler *iface, DWORD dwID, IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
187 return S_OK;
190 static HRESULT STDMETHODCALLTYPE UI_HideUI(IDocHostUIHandler *iface)
192 return S_OK;
195 static HRESULT STDMETHODCALLTYPE UI_UpdateUI(IDocHostUIHandler *iface)
197 return S_OK;
200 static HRESULT STDMETHODCALLTYPE UI_EnableModeless(IDocHostUIHandler *iface, BOOL fEnable)
202 return S_OK;
205 static HRESULT STDMETHODCALLTYPE UI_OnDocWindowActivate(IDocHostUIHandler *iface, BOOL fActivate)
207 return S_OK;
210 static HRESULT STDMETHODCALLTYPE UI_OnFrameWindowActivate(IDocHostUIHandler *iface, BOOL fActivate)
212 return S_OK;
215 static HRESULT STDMETHODCALLTYPE UI_ResizeBorder(IDocHostUIHandler *iface, LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
217 return S_OK;
220 static HRESULT STDMETHODCALLTYPE UI_TranslateAccelerator(IDocHostUIHandler *iface, LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
222 return S_FALSE;
225 static HRESULT STDMETHODCALLTYPE UI_GetOptionKeyPath(IDocHostUIHandler *iface, LPOLESTR *pchKey, DWORD dw)
227 return S_FALSE;
230 static HRESULT STDMETHODCALLTYPE UI_GetDropTarget(IDocHostUIHandler *iface, IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
232 return S_FALSE;
235 static HRESULT STDMETHODCALLTYPE UI_GetExternal(IDocHostUIHandler *iface, IDispatch **ppDispatch)
237 *ppDispatch = NULL;
238 return S_FALSE;
241 static HRESULT STDMETHODCALLTYPE UI_TranslateUrl(IDocHostUIHandler *iface, DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
243 *ppchURLOut = NULL;
244 return S_FALSE;
247 static HRESULT STDMETHODCALLTYPE UI_FilterDataObject(IDocHostUIHandler *iface, IDataObject *pDO, IDataObject **ppDORet)
249 *ppDORet = NULL;
250 return S_FALSE;
253 static const IDocHostUIHandlerVtbl MyIDocHostUIHandlerTable =
255 UI_QueryInterface,
256 UI_AddRef,
257 UI_Release,
258 UI_ShowContextMenu,
259 UI_GetHostInfo,
260 UI_ShowUI,
261 UI_HideUI,
262 UI_UpdateUI,
263 UI_EnableModeless,
264 UI_OnDocWindowActivate,
265 UI_OnFrameWindowActivate,
266 UI_ResizeBorder,
267 UI_TranslateAccelerator,
268 UI_GetOptionKeyPath,
269 UI_GetDropTarget,
270 UI_GetExternal,
271 UI_TranslateUrl,
272 UI_FilterDataObject
275 static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface)
277 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface);
280 static HRESULT STDMETHODCALLTYPE InPlace_QueryInterface(IOleInPlaceSite *iface, REFIID riid, LPVOID *ppvObj)
282 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
284 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
287 static ULONG STDMETHODCALLTYPE InPlace_AddRef(IOleInPlaceSite *iface)
289 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
291 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
294 static ULONG STDMETHODCALLTYPE InPlace_Release(IOleInPlaceSite *iface)
296 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
298 return IOleClientSite_Release(&This->IOleClientSite_iface);
301 static HRESULT STDMETHODCALLTYPE InPlace_GetWindow(IOleInPlaceSite *iface, HWND *lphwnd)
303 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
304 *lphwnd = This->hwndWindow;
306 return S_OK;
309 static HRESULT STDMETHODCALLTYPE InPlace_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
311 return E_NOTIMPL;
314 static HRESULT STDMETHODCALLTYPE InPlace_CanInPlaceActivate(IOleInPlaceSite *iface)
316 return S_OK;
319 static HRESULT STDMETHODCALLTYPE InPlace_OnInPlaceActivate(IOleInPlaceSite *iface)
321 return S_OK;
324 static HRESULT STDMETHODCALLTYPE InPlace_OnUIActivate(IOleInPlaceSite *iface)
326 return S_OK;
329 static HRESULT STDMETHODCALLTYPE InPlace_GetWindowContext(IOleInPlaceSite *iface, LPOLEINPLACEFRAME *lplpFrame, LPOLEINPLACEUIWINDOW *lplpDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
331 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
333 *lplpFrame = &This->IOleInPlaceFrame_iface;
334 IOleInPlaceFrame_AddRef(&This->IOleInPlaceFrame_iface);
336 *lplpDoc = NULL;
338 lpFrameInfo->fMDIApp = FALSE;
339 lpFrameInfo->hwndFrame = This->hwndWindow;
340 lpFrameInfo->haccel = NULL;
341 lpFrameInfo->cAccelEntries = 0;
343 return S_OK;
346 static HRESULT STDMETHODCALLTYPE InPlace_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
348 return E_NOTIMPL;
351 static HRESULT STDMETHODCALLTYPE InPlace_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
353 return S_OK;
356 static HRESULT STDMETHODCALLTYPE InPlace_OnInPlaceDeactivate(IOleInPlaceSite *iface)
358 return S_OK;
361 static HRESULT STDMETHODCALLTYPE InPlace_DiscardUndoState(IOleInPlaceSite *iface)
363 return E_NOTIMPL;
366 static HRESULT STDMETHODCALLTYPE InPlace_DeactivateAndUndo(IOleInPlaceSite *iface)
368 return E_NOTIMPL;
371 static HRESULT STDMETHODCALLTYPE InPlace_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
373 IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface);
374 IOleInPlaceObject *inplace;
376 if (IOleObject_QueryInterface(This->pBrowserObject, &IID_IOleInPlaceObject,
377 (void **)&inplace) == S_OK)
379 IOleInPlaceObject_SetObjectRects(inplace, lprcPosRect, lprcPosRect);
380 IOleInPlaceObject_Release(inplace);
383 return S_OK;
386 static const IOleInPlaceSiteVtbl MyIOleInPlaceSiteTable =
388 InPlace_QueryInterface,
389 InPlace_AddRef,
390 InPlace_Release,
391 InPlace_GetWindow,
392 InPlace_ContextSensitiveHelp,
393 InPlace_CanInPlaceActivate,
394 InPlace_OnInPlaceActivate,
395 InPlace_OnUIActivate,
396 InPlace_GetWindowContext,
397 InPlace_Scroll,
398 InPlace_OnUIDeactivate,
399 InPlace_OnInPlaceDeactivate,
400 InPlace_DiscardUndoState,
401 InPlace_DeactivateAndUndo,
402 InPlace_OnPosRectChange
405 static inline IOleClientSiteImpl *impl_from_IOleInPlaceFrame(IOleInPlaceFrame *iface)
407 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceFrame_iface);
410 static HRESULT STDMETHODCALLTYPE Frame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, LPVOID *ppvObj)
412 IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
414 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj);
417 static ULONG STDMETHODCALLTYPE Frame_AddRef(IOleInPlaceFrame *iface)
419 IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
421 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
424 static ULONG STDMETHODCALLTYPE Frame_Release(IOleInPlaceFrame *iface)
426 IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
428 return IOleClientSite_Release(&This->IOleClientSite_iface);
431 static HRESULT STDMETHODCALLTYPE Frame_GetWindow(IOleInPlaceFrame *iface, HWND *lphwnd)
433 IOleClientSiteImpl *This = impl_from_IOleInPlaceFrame(iface);
434 *lphwnd = This->hwndWindow;
436 return S_OK;
439 static HRESULT STDMETHODCALLTYPE Frame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
441 return E_NOTIMPL;
444 static HRESULT STDMETHODCALLTYPE Frame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
446 return E_NOTIMPL;
449 static HRESULT STDMETHODCALLTYPE Frame_RequestBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
451 return E_NOTIMPL;
454 static HRESULT STDMETHODCALLTYPE Frame_SetBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
456 return E_NOTIMPL;
459 static HRESULT STDMETHODCALLTYPE Frame_SetActiveObject(IOleInPlaceFrame *iface, IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
461 return S_OK;
464 static HRESULT STDMETHODCALLTYPE Frame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
466 return E_NOTIMPL;
469 static HRESULT STDMETHODCALLTYPE Frame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
471 return S_OK;
474 static HRESULT STDMETHODCALLTYPE Frame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
476 return E_NOTIMPL;
479 static HRESULT STDMETHODCALLTYPE Frame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
481 return S_OK;
484 static HRESULT STDMETHODCALLTYPE Frame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
486 return S_OK;
489 static HRESULT STDMETHODCALLTYPE Frame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
491 return E_NOTIMPL;
494 static const IOleInPlaceFrameVtbl MyIOleInPlaceFrameTable =
496 Frame_QueryInterface,
497 Frame_AddRef,
498 Frame_Release,
499 Frame_GetWindow,
500 Frame_ContextSensitiveHelp,
501 Frame_GetBorder,
502 Frame_RequestBorderSpace,
503 Frame_SetBorderSpace,
504 Frame_SetActiveObject,
505 Frame_InsertMenus,
506 Frame_SetMenu,
507 Frame_RemoveMenus,
508 Frame_SetStatusText,
509 Frame_EnableModeless,
510 Frame_TranslateAccelerator
513 static HRESULT STDMETHODCALLTYPE Storage_QueryInterface(IStorage *This, REFIID riid, LPVOID *ppvObj)
515 return E_NOTIMPL;
518 static ULONG STDMETHODCALLTYPE Storage_AddRef(IStorage *This)
520 return 1;
523 static ULONG STDMETHODCALLTYPE Storage_Release(IStorage *This)
525 return 2;
528 static HRESULT STDMETHODCALLTYPE Storage_CreateStream(IStorage *This, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
530 return E_NOTIMPL;
533 static HRESULT STDMETHODCALLTYPE Storage_OpenStream(IStorage *This, const WCHAR * pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
535 return E_NOTIMPL;
538 static HRESULT STDMETHODCALLTYPE Storage_CreateStorage(IStorage *This, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg)
540 return E_NOTIMPL;
543 static HRESULT STDMETHODCALLTYPE Storage_OpenStorage(IStorage *This, const WCHAR * pwcsName, IStorage * pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
545 return E_NOTIMPL;
548 static HRESULT STDMETHODCALLTYPE Storage_CopyTo(IStorage *This, DWORD ciidExclude, IID const *rgiidExclude, SNB snbExclude,IStorage *pstgDest)
550 return E_NOTIMPL;
553 static HRESULT STDMETHODCALLTYPE Storage_MoveElementTo(IStorage *This, const OLECHAR *pwcsName,IStorage * pstgDest, const OLECHAR *pwcsNewName, DWORD grfFlags)
555 return E_NOTIMPL;
558 static HRESULT STDMETHODCALLTYPE Storage_Commit(IStorage *This, DWORD grfCommitFlags)
560 return E_NOTIMPL;
563 static HRESULT STDMETHODCALLTYPE Storage_Revert(IStorage *This)
565 return E_NOTIMPL;
568 static HRESULT STDMETHODCALLTYPE Storage_EnumElements(IStorage *This, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
570 return E_NOTIMPL;
573 static HRESULT STDMETHODCALLTYPE Storage_DestroyElement(IStorage *This, const OLECHAR *pwcsName)
575 return E_NOTIMPL;
578 static HRESULT STDMETHODCALLTYPE Storage_RenameElement(IStorage *This, const WCHAR *pwcsOldName, const WCHAR *pwcsNewName)
580 return E_NOTIMPL;
583 static HRESULT STDMETHODCALLTYPE Storage_SetElementTimes(IStorage *This, const WCHAR *pwcsName, FILETIME const *pctime, FILETIME const *patime, FILETIME const *pmtime)
585 return E_NOTIMPL;
588 static HRESULT STDMETHODCALLTYPE Storage_SetClass(IStorage *This, REFCLSID clsid)
590 return S_OK;
593 static HRESULT STDMETHODCALLTYPE Storage_SetStateBits(IStorage *This, DWORD grfStateBits, DWORD grfMask)
595 return E_NOTIMPL;
598 static HRESULT STDMETHODCALLTYPE Storage_Stat(IStorage *This, STATSTG *pstatstg, DWORD grfStatFlag)
600 return E_NOTIMPL;
603 static const IStorageVtbl MyIStorageTable =
605 Storage_QueryInterface,
606 Storage_AddRef,
607 Storage_Release,
608 Storage_CreateStream,
609 Storage_OpenStream,
610 Storage_CreateStorage,
611 Storage_OpenStorage,
612 Storage_CopyTo,
613 Storage_MoveElementTo,
614 Storage_Commit,
615 Storage_Revert,
616 Storage_EnumElements,
617 Storage_DestroyElement,
618 Storage_RenameElement,
619 Storage_SetElementTimes,
620 Storage_SetClass,
621 Storage_SetStateBits,
622 Storage_Stat
625 static IStorage MyIStorage = { &MyIStorageTable };
627 BOOL InitWebBrowser(HHInfo *info, HWND hwndParent)
629 IOleClientSiteImpl *iOleClientSiteImpl;
630 IOleInPlaceObject *inplace;
631 IOleObject *browserObject;
632 IWebBrowser2 *webBrowser2;
633 HRESULT hr;
634 RECT rc;
636 iOleClientSiteImpl = heap_alloc_zero(sizeof(IOleClientSiteImpl));
637 if (!iOleClientSiteImpl)
638 return FALSE;
640 iOleClientSiteImpl->ref = 1;
641 iOleClientSiteImpl->IOleClientSite_iface.lpVtbl = &MyIOleClientSiteTable;
642 iOleClientSiteImpl->IOleInPlaceSite_iface.lpVtbl = &MyIOleInPlaceSiteTable;
643 iOleClientSiteImpl->IOleInPlaceFrame_iface.lpVtbl = &MyIOleInPlaceFrameTable;
644 iOleClientSiteImpl->hwndWindow = hwndParent;
645 iOleClientSiteImpl->IDocHostUIHandler_iface.lpVtbl = &MyIDocHostUIHandlerTable;
647 hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, OLERENDER_DRAW, 0,
648 &iOleClientSiteImpl->IOleClientSite_iface, &MyIStorage,
649 (void **)&browserObject);
651 info->client_site = &iOleClientSiteImpl->IOleClientSite_iface;
652 info->wb_object = browserObject;
654 if (FAILED(hr)) goto error;
656 /* make the browser object accessible to the IOleClientSite implementation */
657 iOleClientSiteImpl->pBrowserObject = browserObject;
659 GetClientRect(hwndParent, &rc);
661 hr = OleSetContainedObject((struct IUnknown *)browserObject, TRUE);
662 if (FAILED(hr)) goto error;
664 hr = IOleObject_DoVerb(browserObject, OLEIVERB_SHOW, NULL,
665 &iOleClientSiteImpl->IOleClientSite_iface,
666 -1, hwndParent, &rc);
667 if (FAILED(hr)) goto error;
669 hr = IOleObject_QueryInterface(browserObject, &IID_IOleInPlaceObject, (void**)&inplace);
670 if (FAILED(hr)) goto error;
672 IOleInPlaceObject_SetObjectRects(inplace, &rc, &rc);
673 IOleInPlaceObject_Release(inplace);
675 hr = IOleObject_QueryInterface(browserObject, &IID_IWebBrowser2,
676 (void **)&webBrowser2);
677 if (SUCCEEDED(hr))
679 info->web_browser = webBrowser2;
680 return TRUE;
683 error:
684 ReleaseWebBrowser(info);
685 heap_free(iOleClientSiteImpl);
687 return FALSE;
690 void ReleaseWebBrowser(HHInfo *info)
692 HRESULT hres;
694 if (info->web_browser)
696 IWebBrowser2_Release(info->web_browser);
697 info->web_browser = NULL;
700 if (info->client_site)
702 IOleClientSite_Release(info->client_site);
703 info->client_site = NULL;
706 if(info->wb_object) {
707 IOleInPlaceSite *inplace;
709 hres = IOleObject_QueryInterface(info->wb_object, &IID_IOleInPlaceSite, (void**)&inplace);
710 if(SUCCEEDED(hres)) {
711 IOleInPlaceSite_OnInPlaceDeactivate(inplace);
712 IOleInPlaceSite_Release(inplace);
715 IOleObject_SetClientSite(info->wb_object, NULL);
717 IOleObject_Release(info->wb_object);
718 info->wb_object = NULL;
722 void ResizeWebBrowser(HHInfo *info, DWORD dwWidth, DWORD dwHeight)
724 if (!info->web_browser)
725 return;
727 IWebBrowser2_put_Width(info->web_browser, dwWidth);
728 IWebBrowser2_put_Height(info->web_browser, dwHeight);
731 void DoPageAction(HHInfo *info, DWORD dwAction)
733 IWebBrowser2 *pWebBrowser2 = info->web_browser;
735 if (!pWebBrowser2)
736 return;
738 switch (dwAction)
740 case WB_GOBACK:
741 IWebBrowser2_GoBack(pWebBrowser2);
742 break;
743 case WB_GOFORWARD:
744 IWebBrowser2_GoForward(pWebBrowser2);
745 break;
746 case WB_GOHOME:
747 IWebBrowser2_GoHome(pWebBrowser2);
748 break;
749 case WB_SEARCH:
750 IWebBrowser2_GoSearch(pWebBrowser2);
751 break;
752 case WB_REFRESH:
753 IWebBrowser2_Refresh(pWebBrowser2);
754 break;
755 case WB_STOP:
756 IWebBrowser2_Stop(pWebBrowser2);
757 break;
758 case WB_PRINT:
759 IWebBrowser2_ExecWB(pWebBrowser2, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
760 break;