appwiz.cpl: Fix compilation on systems that don't support nameless unions.
[wine.git] / dlls / hhctrl.ocx / webbrowser.c
blobc9caa38f1fa11ab4d6ae8f75600c5fda2de42aaa
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 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
29 typedef struct IOleClientSiteImpl
31 const IOleClientSiteVtbl *lpVtbl;
32 const IOleInPlaceSiteVtbl *lpvtblOleInPlaceSite;
33 const IOleInPlaceFrameVtbl *lpvtblOleInPlaceFrame;
34 const IDocHostUIHandlerVtbl *lpvtblDocHostUIHandler;
36 /* IOleClientSiteImpl data */
37 IOleObject *pBrowserObject;
38 LONG ref;
40 /* IOleInPlaceFrame data */
41 HWND hwndWindow;
42 } IOleClientSiteImpl;
44 #define CLIENTSITE(x) ((IOleClientSite*) &(x)->lpVtbl)
45 #define DOCHOSTUI(x) ((IDocHostUIHandler*) &(x)->lpvtblDocHostUIHandler)
46 #define INPLACESITE(x) ((IOleInPlaceSite*) &(x)->lpvtblOleInPlaceSite)
47 #define INPLACEFRAME(x) ((IOleInPlaceFrame*) &(x)->lpvtblOleInPlaceFrame)
49 static HRESULT STDMETHODCALLTYPE Site_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppvObj)
51 ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
53 *ppvObj = NULL;
55 if (IsEqualIID(riid, &IID_IUnknown)) {
56 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppvObj);
57 *ppvObj = CLIENTSITE(This);
58 }else if(IsEqualIID(riid, &IID_IOleClientSite)) {
59 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppvObj);
60 *ppvObj = CLIENTSITE(This);
61 }else if (IsEqualIID(riid, &IID_IOleInPlaceSite)) {
62 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppvObj);
63 *ppvObj = &(This->lpvtblOleInPlaceSite);
64 }else if (IsEqualIID(riid, &IID_IOleInPlaceFrame)) {
65 TRACE("(%p)->(IID_IOleInPlaceFrame %p)\n", This, ppvObj);
66 *ppvObj = &(This->lpvtblOleInPlaceSite);
67 }else if (IsEqualIID(riid, &IID_IDocHostUIHandler)) {
68 TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppvObj);
69 *ppvObj = &(This->lpvtblDocHostUIHandler);
70 }else {
71 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
72 return E_NOINTERFACE;
75 IUnknown_AddRef((IUnknown*)*ppvObj);
76 return S_OK;
79 static ULONG STDMETHODCALLTYPE Site_AddRef(IOleClientSite *iface)
81 ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
82 LONG ref = InterlockedIncrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, ref);
86 return ref;
89 static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
91 ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
92 LONG ref = InterlockedDecrement(&This->ref);
94 TRACE("(%p) ref=%d\n", This, ref);
96 if(!ref)
97 heap_free(This);
99 return ref;
102 static HRESULT STDMETHODCALLTYPE Site_SaveObject(IOleClientSite *iface)
104 return E_NOTIMPL;
107 static HRESULT STDMETHODCALLTYPE Site_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
109 return E_NOTIMPL;
112 static HRESULT STDMETHODCALLTYPE Site_GetContainer(IOleClientSite *iface, LPOLECONTAINER *ppContainer)
114 *ppContainer = NULL;
116 return E_NOINTERFACE;
119 static HRESULT STDMETHODCALLTYPE Site_ShowObject(IOleClientSite *iface)
121 return NOERROR;
124 static HRESULT STDMETHODCALLTYPE Site_OnShowWindow(IOleClientSite *iface, BOOL fShow)
126 return E_NOTIMPL;
129 static HRESULT STDMETHODCALLTYPE Site_RequestNewObjectLayout(IOleClientSite *iface)
131 return E_NOTIMPL;
134 static const IOleClientSiteVtbl MyIOleClientSiteTable =
136 Site_QueryInterface,
137 Site_AddRef,
138 Site_Release,
139 Site_SaveObject,
140 Site_GetMoniker,
141 Site_GetContainer,
142 Site_ShowObject,
143 Site_OnShowWindow,
144 Site_RequestNewObjectLayout
147 static HRESULT STDMETHODCALLTYPE UI_QueryInterface(IDocHostUIHandler *iface, REFIID riid, LPVOID *ppvObj)
149 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
151 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
154 static ULONG STDMETHODCALLTYPE UI_AddRef(IDocHostUIHandler *iface)
156 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
158 return IOleClientSite_AddRef(CLIENTSITE(This));
161 static ULONG STDMETHODCALLTYPE UI_Release(IDocHostUIHandler * iface)
163 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
165 return IOleClientSite_Release(CLIENTSITE(This));
168 static HRESULT STDMETHODCALLTYPE UI_ShowContextMenu(IDocHostUIHandler *iface, DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
170 return S_OK;
173 static HRESULT STDMETHODCALLTYPE UI_GetHostInfo(IDocHostUIHandler *iface, DOCHOSTUIINFO *pInfo)
175 pInfo->cbSize = sizeof(DOCHOSTUIINFO);
176 pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
177 pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
179 return S_OK;
182 static HRESULT STDMETHODCALLTYPE UI_ShowUI(IDocHostUIHandler *iface, DWORD dwID, IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
184 return S_OK;
187 static HRESULT STDMETHODCALLTYPE UI_HideUI(IDocHostUIHandler *iface)
189 return S_OK;
192 static HRESULT STDMETHODCALLTYPE UI_UpdateUI(IDocHostUIHandler *iface)
194 return S_OK;
197 static HRESULT STDMETHODCALLTYPE UI_EnableModeless(IDocHostUIHandler *iface, BOOL fEnable)
199 return S_OK;
202 static HRESULT STDMETHODCALLTYPE UI_OnDocWindowActivate(IDocHostUIHandler *iface, BOOL fActivate)
204 return S_OK;
207 static HRESULT STDMETHODCALLTYPE UI_OnFrameWindowActivate(IDocHostUIHandler *iface, BOOL fActivate)
209 return S_OK;
212 static HRESULT STDMETHODCALLTYPE UI_ResizeBorder(IDocHostUIHandler *iface, LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
214 return S_OK;
217 static HRESULT STDMETHODCALLTYPE UI_TranslateAccelerator(IDocHostUIHandler *iface, LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
219 return S_FALSE;
222 static HRESULT STDMETHODCALLTYPE UI_GetOptionKeyPath(IDocHostUIHandler *iface, LPOLESTR *pchKey, DWORD dw)
224 return S_FALSE;
227 static HRESULT STDMETHODCALLTYPE UI_GetDropTarget(IDocHostUIHandler *iface, IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
229 return S_FALSE;
232 static HRESULT STDMETHODCALLTYPE UI_GetExternal(IDocHostUIHandler *iface, IDispatch **ppDispatch)
234 *ppDispatch = NULL;
235 return S_FALSE;
238 static HRESULT STDMETHODCALLTYPE UI_TranslateUrl(IDocHostUIHandler *iface, DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
240 *ppchURLOut = NULL;
241 return S_FALSE;
244 static HRESULT STDMETHODCALLTYPE UI_FilterDataObject(IDocHostUIHandler *iface, IDataObject *pDO, IDataObject **ppDORet)
246 *ppDORet = NULL;
247 return S_FALSE;
250 static const IDocHostUIHandlerVtbl MyIDocHostUIHandlerTable =
252 UI_QueryInterface,
253 UI_AddRef,
254 UI_Release,
255 UI_ShowContextMenu,
256 UI_GetHostInfo,
257 UI_ShowUI,
258 UI_HideUI,
259 UI_UpdateUI,
260 UI_EnableModeless,
261 UI_OnDocWindowActivate,
262 UI_OnFrameWindowActivate,
263 UI_ResizeBorder,
264 UI_TranslateAccelerator,
265 UI_GetOptionKeyPath,
266 UI_GetDropTarget,
267 UI_GetExternal,
268 UI_TranslateUrl,
269 UI_FilterDataObject
272 static HRESULT STDMETHODCALLTYPE InPlace_QueryInterface(IOleInPlaceSite *iface, REFIID riid, LPVOID *ppvObj)
274 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
276 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
279 static ULONG STDMETHODCALLTYPE InPlace_AddRef(IOleInPlaceSite *iface)
281 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
283 return IOleClientSite_AddRef(CLIENTSITE(This));
286 static ULONG STDMETHODCALLTYPE InPlace_Release(IOleInPlaceSite *iface)
288 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
290 return IOleClientSite_Release(CLIENTSITE(This));
293 static HRESULT STDMETHODCALLTYPE InPlace_GetWindow(IOleInPlaceSite *iface, HWND *lphwnd)
295 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
296 *lphwnd = This->hwndWindow;
298 return S_OK;
301 static HRESULT STDMETHODCALLTYPE InPlace_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
303 return E_NOTIMPL;
306 static HRESULT STDMETHODCALLTYPE InPlace_CanInPlaceActivate(IOleInPlaceSite *iface)
308 return S_OK;
311 static HRESULT STDMETHODCALLTYPE InPlace_OnInPlaceActivate(IOleInPlaceSite *iface)
313 return S_OK;
316 static HRESULT STDMETHODCALLTYPE InPlace_OnUIActivate(IOleInPlaceSite *iface)
318 return S_OK;
321 static HRESULT STDMETHODCALLTYPE InPlace_GetWindowContext(IOleInPlaceSite *iface, LPOLEINPLACEFRAME *lplpFrame, LPOLEINPLACEUIWINDOW *lplpDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
323 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
325 *lplpFrame = INPLACEFRAME(This);
326 IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
328 *lplpDoc = NULL;
330 lpFrameInfo->fMDIApp = FALSE;
331 lpFrameInfo->hwndFrame = This->hwndWindow;
332 lpFrameInfo->haccel = NULL;
333 lpFrameInfo->cAccelEntries = 0;
335 return S_OK;
338 static HRESULT STDMETHODCALLTYPE InPlace_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
340 return E_NOTIMPL;
343 static HRESULT STDMETHODCALLTYPE InPlace_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
345 return S_OK;
348 static HRESULT STDMETHODCALLTYPE InPlace_OnInPlaceDeactivate(IOleInPlaceSite *iface)
350 return S_OK;
353 static HRESULT STDMETHODCALLTYPE InPlace_DiscardUndoState(IOleInPlaceSite *iface)
355 return E_NOTIMPL;
358 static HRESULT STDMETHODCALLTYPE InPlace_DeactivateAndUndo(IOleInPlaceSite *iface)
360 return E_NOTIMPL;
363 static HRESULT STDMETHODCALLTYPE InPlace_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
365 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
366 IOleInPlaceObject *inplace;
368 if (!IOleObject_QueryInterface(This->pBrowserObject, &IID_IOleInPlaceObject, (void **)&inplace))
369 IOleInPlaceObject_SetObjectRects(inplace, lprcPosRect, lprcPosRect);
371 return S_OK;
374 static const IOleInPlaceSiteVtbl MyIOleInPlaceSiteTable =
376 InPlace_QueryInterface,
377 InPlace_AddRef,
378 InPlace_Release,
379 InPlace_GetWindow,
380 InPlace_ContextSensitiveHelp,
381 InPlace_CanInPlaceActivate,
382 InPlace_OnInPlaceActivate,
383 InPlace_OnUIActivate,
384 InPlace_GetWindowContext,
385 InPlace_Scroll,
386 InPlace_OnUIDeactivate,
387 InPlace_OnInPlaceDeactivate,
388 InPlace_DiscardUndoState,
389 InPlace_DeactivateAndUndo,
390 InPlace_OnPosRectChange
393 static HRESULT STDMETHODCALLTYPE Frame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, LPVOID *ppvObj)
395 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
397 return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
400 static ULONG STDMETHODCALLTYPE Frame_AddRef(IOleInPlaceFrame *iface)
402 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
404 return IOleClientSite_AddRef(CLIENTSITE(This));
407 static ULONG STDMETHODCALLTYPE Frame_Release(IOleInPlaceFrame *iface)
409 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
411 return IOleClientSite_Release(CLIENTSITE(This));
414 static HRESULT STDMETHODCALLTYPE Frame_GetWindow(IOleInPlaceFrame *iface, HWND *lphwnd)
416 ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
417 *lphwnd = This->hwndWindow;
419 return S_OK;
422 static HRESULT STDMETHODCALLTYPE Frame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
424 return E_NOTIMPL;
427 static HRESULT STDMETHODCALLTYPE Frame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
429 return E_NOTIMPL;
432 static HRESULT STDMETHODCALLTYPE Frame_RequestBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
434 return E_NOTIMPL;
437 static HRESULT STDMETHODCALLTYPE Frame_SetBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
439 return E_NOTIMPL;
442 static HRESULT STDMETHODCALLTYPE Frame_SetActiveObject(IOleInPlaceFrame *iface, IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
444 return S_OK;
447 static HRESULT STDMETHODCALLTYPE Frame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
449 return E_NOTIMPL;
452 static HRESULT STDMETHODCALLTYPE Frame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
454 return S_OK;
457 static HRESULT STDMETHODCALLTYPE Frame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
459 return E_NOTIMPL;
462 static HRESULT STDMETHODCALLTYPE Frame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
464 return S_OK;
467 static HRESULT STDMETHODCALLTYPE Frame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
469 return S_OK;
472 static HRESULT STDMETHODCALLTYPE Frame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
474 return E_NOTIMPL;
477 static const IOleInPlaceFrameVtbl MyIOleInPlaceFrameTable =
479 Frame_QueryInterface,
480 Frame_AddRef,
481 Frame_Release,
482 Frame_GetWindow,
483 Frame_ContextSensitiveHelp,
484 Frame_GetBorder,
485 Frame_RequestBorderSpace,
486 Frame_SetBorderSpace,
487 Frame_SetActiveObject,
488 Frame_InsertMenus,
489 Frame_SetMenu,
490 Frame_RemoveMenus,
491 Frame_SetStatusText,
492 Frame_EnableModeless,
493 Frame_TranslateAccelerator
496 static HRESULT STDMETHODCALLTYPE Storage_QueryInterface(IStorage *This, REFIID riid, LPVOID *ppvObj)
498 return E_NOTIMPL;
501 static ULONG STDMETHODCALLTYPE Storage_AddRef(IStorage *This)
503 return 1;
506 static ULONG STDMETHODCALLTYPE Storage_Release(IStorage *This)
508 return 2;
511 static HRESULT STDMETHODCALLTYPE Storage_CreateStream(IStorage *This, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
513 return E_NOTIMPL;
516 static HRESULT STDMETHODCALLTYPE Storage_OpenStream(IStorage *This, const WCHAR * pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
518 return E_NOTIMPL;
521 static HRESULT STDMETHODCALLTYPE Storage_CreateStorage(IStorage *This, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg)
523 return E_NOTIMPL;
526 static HRESULT STDMETHODCALLTYPE Storage_OpenStorage(IStorage *This, const WCHAR * pwcsName, IStorage * pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
528 return E_NOTIMPL;
531 static HRESULT STDMETHODCALLTYPE Storage_CopyTo(IStorage *This, DWORD ciidExclude, IID const *rgiidExclude, SNB snbExclude,IStorage *pstgDest)
533 return E_NOTIMPL;
536 static HRESULT STDMETHODCALLTYPE Storage_MoveElementTo(IStorage *This, const OLECHAR *pwcsName,IStorage * pstgDest, const OLECHAR *pwcsNewName, DWORD grfFlags)
538 return E_NOTIMPL;
541 static HRESULT STDMETHODCALLTYPE Storage_Commit(IStorage *This, DWORD grfCommitFlags)
543 return E_NOTIMPL;
546 static HRESULT STDMETHODCALLTYPE Storage_Revert(IStorage *This)
548 return E_NOTIMPL;
551 static HRESULT STDMETHODCALLTYPE Storage_EnumElements(IStorage *This, DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
553 return E_NOTIMPL;
556 static HRESULT STDMETHODCALLTYPE Storage_DestroyElement(IStorage *This, const OLECHAR *pwcsName)
558 return E_NOTIMPL;
561 static HRESULT STDMETHODCALLTYPE Storage_RenameElement(IStorage *This, const WCHAR *pwcsOldName, const WCHAR *pwcsNewName)
563 return E_NOTIMPL;
566 static HRESULT STDMETHODCALLTYPE Storage_SetElementTimes(IStorage *This, const WCHAR *pwcsName, FILETIME const *pctime, FILETIME const *patime, FILETIME const *pmtime)
568 return E_NOTIMPL;
571 static HRESULT STDMETHODCALLTYPE Storage_SetClass(IStorage *This, REFCLSID clsid)
573 return S_OK;
576 static HRESULT STDMETHODCALLTYPE Storage_SetStateBits(IStorage *This, DWORD grfStateBits, DWORD grfMask)
578 return E_NOTIMPL;
581 static HRESULT STDMETHODCALLTYPE Storage_Stat(IStorage *This, STATSTG *pstatstg, DWORD grfStatFlag)
583 return E_NOTIMPL;
586 static const IStorageVtbl MyIStorageTable =
588 Storage_QueryInterface,
589 Storage_AddRef,
590 Storage_Release,
591 Storage_CreateStream,
592 Storage_OpenStream,
593 Storage_CreateStorage,
594 Storage_OpenStorage,
595 Storage_CopyTo,
596 Storage_MoveElementTo,
597 Storage_Commit,
598 Storage_Revert,
599 Storage_EnumElements,
600 Storage_DestroyElement,
601 Storage_RenameElement,
602 Storage_SetElementTimes,
603 Storage_SetClass,
604 Storage_SetStateBits,
605 Storage_Stat
608 static IStorage MyIStorage = { &MyIStorageTable };
610 BOOL InitWebBrowser(HHInfo *info, HWND hwndParent)
612 IOleClientSiteImpl *iOleClientSiteImpl;
613 IOleInPlaceObject *inplace;
614 IOleObject *browserObject;
615 IWebBrowser2 *webBrowser2;
616 HRESULT hr;
617 RECT rc;
619 iOleClientSiteImpl = heap_alloc_zero(sizeof(IOleClientSiteImpl));
620 if (!iOleClientSiteImpl)
621 return FALSE;
623 iOleClientSiteImpl->ref = 1;
624 iOleClientSiteImpl->lpVtbl = &MyIOleClientSiteTable;
625 iOleClientSiteImpl->lpvtblOleInPlaceSite = &MyIOleInPlaceSiteTable;
626 iOleClientSiteImpl->lpvtblOleInPlaceFrame = &MyIOleInPlaceFrameTable;
627 iOleClientSiteImpl->hwndWindow = hwndParent;
628 iOleClientSiteImpl->lpvtblDocHostUIHandler = &MyIDocHostUIHandlerTable;
630 hr = OleCreate(&CLSID_WebBrowser, &IID_IOleObject, OLERENDER_DRAW, 0,
631 (IOleClientSite *)iOleClientSiteImpl, &MyIStorage,
632 (void **)&browserObject);
634 info->client_site = (IOleClientSite *)iOleClientSiteImpl;
635 info->wb_object = browserObject;
637 if (FAILED(hr)) goto error;
639 /* make the browser object accessible to the IOleClientSite implementation */
640 iOleClientSiteImpl->pBrowserObject = browserObject;
642 GetClientRect(hwndParent, &rc);
644 hr = OleSetContainedObject((struct IUnknown *)browserObject, TRUE);
645 if (FAILED(hr)) goto error;
647 hr = IOleObject_DoVerb(browserObject, OLEIVERB_SHOW, NULL,
648 (IOleClientSite *)iOleClientSiteImpl,
649 -1, hwndParent, &rc);
650 if (FAILED(hr)) goto error;
652 hr = IOleObject_QueryInterface(browserObject, &IID_IOleInPlaceObject, (void**)&inplace);
653 if (FAILED(hr)) goto error;
655 IOleInPlaceObject_SetObjectRects(inplace, &rc, &rc);
656 IOleInPlaceObject_Release(inplace);
658 hr = IOleObject_QueryInterface(browserObject, &IID_IWebBrowser2,
659 (void **)&webBrowser2);
660 if (SUCCEEDED(hr))
662 info->web_browser = webBrowser2;
663 return TRUE;
666 error:
667 ReleaseWebBrowser(info);
668 heap_free(iOleClientSiteImpl);
670 return FALSE;
673 void ReleaseWebBrowser(HHInfo *info)
675 HRESULT hres;
677 if (info->web_browser)
679 IWebBrowser2_Release(info->web_browser);
680 info->web_browser = NULL;
683 if (info->client_site)
685 IOleClientSite_Release(info->client_site);
686 info->client_site = NULL;
689 if(info->wb_object) {
690 IOleInPlaceSite *inplace;
692 hres = IOleObject_QueryInterface(info->wb_object, &IID_IOleInPlaceSite, (void**)&inplace);
693 if(SUCCEEDED(hres)) {
694 IOleInPlaceSite_OnInPlaceDeactivate(inplace);
695 IOleInPlaceSite_Release(inplace);
698 IOleObject_SetClientSite(info->wb_object, NULL);
700 IOleObject_Release(info->wb_object);
701 info->wb_object = NULL;
705 void ResizeWebBrowser(HHInfo *info, DWORD dwWidth, DWORD dwHeight)
707 if (!info->web_browser)
708 return;
710 IWebBrowser2_put_Width(info->web_browser, dwWidth);
711 IWebBrowser2_put_Height(info->web_browser, dwHeight);
714 void DoPageAction(HHInfo *info, DWORD dwAction)
716 IWebBrowser2 *pWebBrowser2 = info->web_browser;
718 if (!pWebBrowser2)
719 return;
721 switch (dwAction)
723 case WB_GOBACK:
724 IWebBrowser2_GoBack(pWebBrowser2);
725 break;
726 case WB_GOFORWARD:
727 IWebBrowser2_GoForward(pWebBrowser2);
728 break;
729 case WB_GOHOME:
730 IWebBrowser2_GoHome(pWebBrowser2);
731 break;
732 case WB_SEARCH:
733 IWebBrowser2_GoSearch(pWebBrowser2);
734 break;
735 case WB_REFRESH:
736 IWebBrowser2_Refresh(pWebBrowser2);
737 case WB_STOP:
738 IWebBrowser2_Stop(pWebBrowser2);