2 * Implementation of IOleObject interfaces for WebBrowser control
8 * Copyright 2001 John R. Sheets (for CodeWeavers)
9 * Copyright 2005 Jacek Caban
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
36 HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent);
38 static ATOM shell_embedding_atom = 0;
40 static LRESULT resize_window(WebBrowser *This, LONG width, LONG height)
42 if(This->doc_host.hwnd)
43 SetWindowPos(This->doc_host.hwnd, NULL, 0, 0, width, height,
44 SWP_NOZORDER | SWP_NOACTIVATE);
49 static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
53 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
55 if(msg == WM_CREATE) {
56 This = *(WebBrowser**)lParam;
57 SetPropW(hwnd, wszTHIS, This);
59 This = GetPropW(hwnd, wszTHIS);
64 return resize_window(This, LOWORD(lParam), HIWORD(lParam));
66 return process_dochost_task(&This->doc_host, lParam);
69 return DefWindowProcW(hwnd, msg, wParam, lParam);
72 static void create_shell_embedding_hwnd(WebBrowser *This)
74 IOleInPlaceSite *inplace;
78 static const WCHAR wszShellEmbedding[] =
79 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
81 if(!shell_embedding_atom) {
82 static WNDCLASSEXW wndclass = {
86 0, 0 /* native uses 8 */, NULL, NULL, NULL,
87 (HBRUSH)(COLOR_WINDOW + 1), NULL,
91 wndclass.hInstance = shdocvw_hinstance;
93 RegisterClassExW(&wndclass);
96 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleInPlaceSite, (void**)&inplace);
98 IOleInPlaceSite_GetWindow(inplace, &parent);
99 IOleInPlaceSite_Release(inplace);
102 This->doc_host.frame_hwnd = This->shell_embedding_hwnd = CreateWindowExW(
104 wszShellEmbedding, wszShellEmbedding,
105 WS_CLIPSIBLINGS | WS_CLIPCHILDREN
106 | (parent ? WS_CHILD | WS_TABSTOP : WS_POPUP | WS_MAXIMIZEBOX),
108 NULL, shdocvw_hinstance, This);
110 TRACE("parent=%p hwnd=%p\n", parent, This->shell_embedding_hwnd);
113 static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site)
124 hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite,
125 (void**)&This->inplace);
127 WARN("Could not get IOleInPlaceSite\n");
131 hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace);
133 WARN("CanInPlaceActivate returned: %08x\n", hres);
134 IOleInPlaceSite_Release(This->inplace);
138 hres = IOleInPlaceSite_GetWindow(This->inplace, &parent_hwnd);
140 SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd);
142 IOleInPlaceSite_OnInPlaceActivate(This->inplace);
144 IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow,
145 &This->pos_rect, &This->clip_rect,
148 SetWindowPos(This->shell_embedding_hwnd, NULL,
149 This->pos_rect.left, This->pos_rect.top,
150 This->pos_rect.right-This->pos_rect.left,
151 This->pos_rect.bottom-This->pos_rect.top,
152 SWP_NOZORDER | SWP_SHOWWINDOW);
155 IOleContainer *container;
157 IOleClientSite_ShowObject(This->client);
159 hres = IOleClientSite_GetContainer(This->client, &container);
160 if(SUCCEEDED(hres)) {
162 IOleContainer_Release(This->container);
163 This->container = container;
167 if(This->doc_host.frame)
168 IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd);
173 static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site)
177 static const WCHAR wszitem[] = {'i','t','e','m',0};
181 if(This->shell_embedding_hwnd)
182 ShowWindow(This->shell_embedding_hwnd, SW_SHOW);
186 hres = activate_inplace(This, active_site);
190 IOleInPlaceSite_OnUIActivate(This->inplace);
192 if(This->doc_host.frame)
193 IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, &This->IOleInPlaceActiveObject_iface, wszitem);
195 IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, &This->IOleInPlaceActiveObject_iface, wszitem);
197 if(This->doc_host.frame)
198 IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd);
200 SetFocus(This->shell_embedding_hwnd);
205 static HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
207 IDispatch *disp = NULL;
208 DISPPARAMS dispparams = {NULL, 0};
216 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
218 TRACE("Could not get IDispatch\n");
222 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
223 DISPATCH_PROPERTYGET, &dispparams, res, NULL, NULL);
225 IDispatch_Release(disp);
230 static HRESULT on_offlineconnected_change(WebBrowser *This)
234 get_client_disp_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
236 if(V_VT(&offline) == VT_BOOL)
237 IWebBrowser2_put_Offline(&This->IWebBrowser2_iface, V_BOOL(&offline));
238 else if(V_VT(&offline) != VT_EMPTY)
239 WARN("wrong V_VT(silent) %d\n", V_VT(&offline));
244 static HRESULT on_silent_change(WebBrowser *This)
248 get_client_disp_property(This->client, DISPID_AMBIENT_SILENT, &silent);
250 if(V_VT(&silent) == VT_BOOL)
251 IWebBrowser2_put_Silent(&This->IWebBrowser2_iface, V_BOOL(&silent));
252 else if(V_VT(&silent) != VT_EMPTY)
253 WARN("wrong V_VT(silent) %d\n", V_VT(&silent));
258 static void release_client_site(WebBrowser *This)
260 release_dochost_client(&This->doc_host);
262 if(This->shell_embedding_hwnd) {
263 DestroyWindow(This->shell_embedding_hwnd);
264 This->shell_embedding_hwnd = NULL;
268 IOleInPlaceSite_Release(This->inplace);
269 This->inplace = NULL;
272 if(This->container) {
273 IOleContainer_Release(This->container);
274 This->container = NULL;
278 IOleInPlaceUIWindow_Release(This->uiwindow);
279 This->uiwindow = NULL;
283 IOleClientSite_Release(This->client);
288 /**********************************************************************
289 * Implement the IOleObject interface for the WebBrowser control
292 static inline WebBrowser *impl_from_IOleObject(IOleObject *iface)
294 return CONTAINING_RECORD(iface, WebBrowser, IOleObject_iface);
297 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
299 WebBrowser *This = impl_from_IOleObject(iface);
300 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
303 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
305 WebBrowser *This = impl_from_IOleObject(iface);
306 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
309 static ULONG WINAPI OleObject_Release(IOleObject *iface)
311 WebBrowser *This = impl_from_IOleObject(iface);
312 return IWebBrowser_Release(&This->IWebBrowser2_iface);
315 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
317 WebBrowser *This = impl_from_IOleObject(iface);
318 IDocHostUIHandler *hostui;
319 IOleContainer *container;
323 TRACE("(%p)->(%p)\n", This, pClientSite);
325 if(This->client == pClientSite)
328 release_client_site(This);
331 if(This->doc_host.document)
332 deactivate_document(&This->doc_host);
336 IOleClientSite_AddRef(pClientSite);
337 This->client = pClientSite;
339 hres = IOleClientSite_QueryInterface(This->client, &IID_IDispatch,
342 This->doc_host.client_disp = disp;
344 hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
347 This->doc_host.hostui = hostui;
349 hres = IOleClientSite_GetContainer(This->client, &container);
350 if(SUCCEEDED(hres)) {
351 ITargetContainer *target_container;
353 hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
354 (void**)&target_container);
355 if(SUCCEEDED(hres)) {
356 FIXME("Unsupported ITargetContainer\n");
357 ITargetContainer_Release(target_container);
360 IOleContainer_Release(container);
363 create_shell_embedding_hwnd(This);
365 on_offlineconnected_change(This);
366 on_silent_change(This);
371 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
373 WebBrowser *This = impl_from_IOleObject(iface);
375 TRACE("(%p)->(%p)\n", This, ppClientSite);
381 IOleClientSite_AddRef(This->client);
382 *ppClientSite = This->client;
387 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
388 LPCOLESTR szContainerObj)
390 WebBrowser *This = impl_from_IOleObject(iface);
392 TRACE("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
394 /* We have nothing to do here. */
398 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
400 WebBrowser *This = impl_from_IOleObject(iface);
401 FIXME("(%p)->(%d)\n", This, dwSaveOption);
405 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
407 WebBrowser *This = impl_from_IOleObject(iface);
408 FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
412 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
413 DWORD dwWhichMoniker, LPMONIKER *ppmk)
415 WebBrowser *This = impl_from_IOleObject(iface);
416 FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
420 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
421 BOOL fCreation, DWORD dwReserved)
423 WebBrowser *This = impl_from_IOleObject(iface);
424 FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
428 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
429 LPDATAOBJECT *ppDataObject)
431 WebBrowser *This = impl_from_IOleObject(iface);
432 FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
436 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
437 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
439 WebBrowser *This = impl_from_IOleObject(iface);
441 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
447 TRACE("OLEIVERB_SHOW\n");
448 return activate_ui(This, pActiveSite);
449 case OLEIVERB_UIACTIVATE:
450 TRACE("OLEIVERB_UIACTIVATE\n");
451 return activate_ui(This, pActiveSite);
452 case OLEIVERB_INPLACEACTIVATE:
453 TRACE("OLEIVERB_INPLACEACTIVATE\n");
454 return activate_inplace(This, pActiveSite);
456 TRACE("OLEIVERB_HIDE\n");
457 if(This->shell_embedding_hwnd)
458 ShowWindow(This->shell_embedding_hwnd, SW_HIDE);
461 FIXME("stub for %d\n", iVerb);
468 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
470 WebBrowser *This = impl_from_IOleObject(iface);
471 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
472 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
475 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
477 WebBrowser *This = impl_from_IOleObject(iface);
478 FIXME("(%p)\n", This);
482 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
484 WebBrowser *This = impl_from_IOleObject(iface);
485 FIXME("(%p)\n", This);
489 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
491 WebBrowser *This = impl_from_IOleObject(iface);
492 FIXME("(%p)->(%p)\n", This, pClsid);
496 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
497 LPOLESTR* pszUserType)
499 WebBrowser *This = impl_from_IOleObject(iface);
500 TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
501 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
504 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
506 WebBrowser *This = impl_from_IOleObject(iface);
508 TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
510 /* Tests show that dwDrawAspect is ignored */
511 This->extent = *psizel;
515 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
517 WebBrowser *This = impl_from_IOleObject(iface);
519 TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
521 /* Tests show that dwDrawAspect is ignored */
522 *psizel = This->extent;
526 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
527 DWORD* pdwConnection)
529 WebBrowser *This = impl_from_IOleObject(iface);
530 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
534 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
536 WebBrowser *This = impl_from_IOleObject(iface);
537 FIXME("(%p)->(%d)\n", This, dwConnection);
541 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
543 WebBrowser *This = impl_from_IOleObject(iface);
544 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
548 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
550 WebBrowser *This = impl_from_IOleObject(iface);
552 TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
554 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
555 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
560 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
562 WebBrowser *This = impl_from_IOleObject(iface);
563 FIXME("(%p)->(%p)\n", This, pLogpal);
567 static const IOleObjectVtbl OleObjectVtbl =
569 OleObject_QueryInterface,
572 OleObject_SetClientSite,
573 OleObject_GetClientSite,
574 OleObject_SetHostNames,
576 OleObject_SetMoniker,
577 OleObject_GetMoniker,
578 OleObject_InitFromData,
579 OleObject_GetClipboardData,
583 OleObject_IsUpToDate,
584 OleObject_GetUserClassID,
585 OleObject_GetUserType,
590 OleObject_EnumAdvise,
591 OleObject_GetMiscStatus,
592 OleObject_SetColorScheme
595 /**********************************************************************
596 * Implement the IOleInPlaceObject interface
599 static inline WebBrowser *impl_from_IOleInPlaceObject(IOleInPlaceObject *iface)
601 return CONTAINING_RECORD(iface, WebBrowser, IOleInPlaceObject_iface);
604 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
605 REFIID riid, LPVOID *ppobj)
607 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
608 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
611 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
613 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
614 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
617 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
619 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
620 return IWebBrowser_Release(&This->IWebBrowser2_iface);
623 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
625 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
627 TRACE("(%p)->(%p)\n", This, phwnd);
629 *phwnd = This->shell_embedding_hwnd;
633 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
636 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
637 FIXME("(%p)->(%x)\n", This, fEnterMode);
641 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
643 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
644 FIXME("(%p)\n", This);
647 IOleInPlaceSite_Release(This->inplace);
648 This->inplace = NULL;
654 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
656 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
657 FIXME("(%p)\n", This);
661 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
662 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
664 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
666 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
668 This->pos_rect = *lprcPosRect;
671 This->clip_rect = *lprcClipRect;
673 if(This->shell_embedding_hwnd) {
674 SetWindowPos(This->shell_embedding_hwnd, NULL,
675 lprcPosRect->left, lprcPosRect->top,
676 lprcPosRect->right-lprcPosRect->left,
677 lprcPosRect->bottom-lprcPosRect->top,
678 SWP_NOZORDER | SWP_NOACTIVATE);
684 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
686 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
687 FIXME("(%p)\n", This);
691 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
693 OleInPlaceObject_QueryInterface,
694 OleInPlaceObject_AddRef,
695 OleInPlaceObject_Release,
696 OleInPlaceObject_GetWindow,
697 OleInPlaceObject_ContextSensitiveHelp,
698 OleInPlaceObject_InPlaceDeactivate,
699 OleInPlaceObject_UIDeactivate,
700 OleInPlaceObject_SetObjectRects,
701 OleInPlaceObject_ReactivateAndUndo
704 /**********************************************************************
705 * Implement the IOleControl interface
708 static inline WebBrowser *impl_from_IOleControl(IOleControl *iface)
710 return CONTAINING_RECORD(iface, WebBrowser, IOleControl_iface);
713 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
714 REFIID riid, LPVOID *ppobj)
716 WebBrowser *This = impl_from_IOleControl(iface);
717 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
720 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
722 WebBrowser *This = impl_from_IOleControl(iface);
723 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
726 static ULONG WINAPI OleControl_Release(IOleControl *iface)
728 WebBrowser *This = impl_from_IOleControl(iface);
729 return IWebBrowser_Release(&This->IWebBrowser2_iface);
732 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
734 WebBrowser *This = impl_from_IOleControl(iface);
736 TRACE("(%p)->(%p)\n", This, pCI);
738 /* Tests show that this function should be not implemented */
742 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
744 WebBrowser *This = impl_from_IOleControl(iface);
745 FIXME("(%p)->(%p)\n", This, pMsg);
749 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
751 WebBrowser *This = impl_from_IOleControl(iface);
753 TRACE("(%p)->(%d)\n", This, dispID);
757 /* Unknown means multiple properties changed, so check them all.
758 * BUT the Webbrowser OleControl object doesn't appear to do this.
761 case DISPID_AMBIENT_DLCONTROL:
763 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
764 return on_offlineconnected_change(This);
765 case DISPID_AMBIENT_SILENT:
766 return on_silent_change(This);
769 FIXME("Unknown dispID %d\n", dispID);
773 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
775 WebBrowser *This = impl_from_IOleControl(iface);
776 FIXME("(%p)->(%x)\n", This, bFreeze);
780 static const IOleControlVtbl OleControlVtbl =
782 OleControl_QueryInterface,
785 OleControl_GetControlInfo,
786 OleControl_OnMnemonic,
787 OleControl_OnAmbientPropertyChange,
788 OleControl_FreezeEvents
791 static inline WebBrowser *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
793 return CONTAINING_RECORD(iface, WebBrowser, IOleInPlaceActiveObject_iface);
796 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
797 REFIID riid, void **ppv)
799 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
800 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
803 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
805 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
806 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
809 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
811 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
812 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
815 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
818 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
819 return IOleInPlaceObject_GetWindow(&This->IOleInPlaceObject_iface, phwnd);
822 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
825 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
826 return IOleInPlaceObject_ContextSensitiveHelp(&This->IOleInPlaceObject_iface, fEnterMode);
829 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
832 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
833 IOleInPlaceActiveObject *activeobj;
834 HRESULT hr = S_FALSE;
836 TRACE("(%p)->(%p)\n", This, lpmsg);
838 if(This->doc_host.document) {
839 if(SUCCEEDED(IUnknown_QueryInterface(This->doc_host.document,
840 &IID_IOleInPlaceActiveObject,
841 (void**)&activeobj))) {
842 hr = IOleInPlaceActiveObject_TranslateAccelerator(activeobj, lpmsg);
843 IOleInPlaceActiveObject_Release(activeobj);
853 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
856 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
857 FIXME("(%p)->(%x)\n", This, fActivate);
861 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
864 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
865 FIXME("(%p)->(%x)\n", This, fActivate);
869 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
870 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
872 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
873 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
877 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
880 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
881 FIXME("(%p)->(%x)\n", This, fEnable);
885 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
886 InPlaceActiveObject_QueryInterface,
887 InPlaceActiveObject_AddRef,
888 InPlaceActiveObject_Release,
889 InPlaceActiveObject_GetWindow,
890 InPlaceActiveObject_ContextSensitiveHelp,
891 InPlaceActiveObject_TranslateAccelerator,
892 InPlaceActiveObject_OnFrameWindowActivate,
893 InPlaceActiveObject_OnDocWindowActivate,
894 InPlaceActiveObject_ResizeBorder,
895 InPlaceActiveObject_EnableModeless
898 static inline WebBrowser *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
900 return CONTAINING_RECORD(iface, WebBrowser, IOleCommandTarget_iface);
903 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
904 REFIID riid, void **ppv)
906 WebBrowser *This = impl_from_IOleCommandTarget(iface);
907 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
910 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
912 WebBrowser *This = impl_from_IOleCommandTarget(iface);
913 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
916 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
918 WebBrowser *This = impl_from_IOleCommandTarget(iface);
919 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
922 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
923 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
925 WebBrowser *This = impl_from_IOleCommandTarget(iface);
926 IOleCommandTarget *cmdtrg;
929 TRACE("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
932 if(!This->doc_host.document)
935 /* NOTE: There are probably some commands that we should handle here
936 * instead of forwarding to document object. */
938 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (void**)&cmdtrg);
942 hres = IOleCommandTarget_QueryStatus(cmdtrg, pguidCmdGroup, cCmds, prgCmds, pCmdText);
943 IOleCommandTarget_Release(cmdtrg);
948 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
949 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
952 WebBrowser *This = impl_from_IOleCommandTarget(iface);
953 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
954 nCmdexecopt, pvaIn, pvaOut);
958 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
959 WBOleCommandTarget_QueryInterface,
960 WBOleCommandTarget_AddRef,
961 WBOleCommandTarget_Release,
962 WBOleCommandTarget_QueryStatus,
963 WBOleCommandTarget_Exec
966 void WebBrowser_OleObject_Init(WebBrowser *This)
972 /* default aspect ratio is 96dpi / 96dpi */
974 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
975 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
978 This->IOleObject_iface.lpVtbl = &OleObjectVtbl;
979 This->IOleInPlaceObject_iface.lpVtbl = &OleInPlaceObjectVtbl;
980 This->IOleControl_iface.lpVtbl = &OleControlVtbl;
981 This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
982 This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
984 /* Default size is 50x20 pixels, in himetric units */
985 This->extent.cx = MulDiv( 50, 2540, dpi_x );
986 This->extent.cy = MulDiv( 20, 2540, dpi_y );
989 void WebBrowser_OleObject_Destroy(WebBrowser *This)
991 release_client_site(This);