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 This->frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO);
145 IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow,
146 &This->pos_rect, &This->clip_rect,
149 SetWindowPos(This->shell_embedding_hwnd, NULL,
150 This->pos_rect.left, This->pos_rect.top,
151 This->pos_rect.right-This->pos_rect.left,
152 This->pos_rect.bottom-This->pos_rect.top,
153 SWP_NOZORDER | SWP_SHOWWINDOW);
156 IOleContainer *container;
158 IOleClientSite_ShowObject(This->client);
160 hres = IOleClientSite_GetContainer(This->client, &container);
161 if(SUCCEEDED(hres)) {
163 IOleContainer_Release(This->container);
164 This->container = container;
168 if(This->doc_host.frame)
169 IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd);
174 static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site)
178 static const WCHAR wszitem[] = {'i','t','e','m',0};
182 if(This->shell_embedding_hwnd)
183 ShowWindow(This->shell_embedding_hwnd, SW_SHOW);
187 hres = activate_inplace(This, active_site);
191 IOleInPlaceSite_OnUIActivate(This->inplace);
193 if(This->doc_host.frame)
194 IOleInPlaceFrame_SetActiveObject(This->doc_host.frame, &This->IOleInPlaceActiveObject_iface, wszitem);
196 IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, &This->IOleInPlaceActiveObject_iface, wszitem);
198 if(This->doc_host.frame)
199 IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd);
201 SetFocus(This->shell_embedding_hwnd);
206 static HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
208 IDispatch *disp = NULL;
209 DISPPARAMS dispparams = {NULL, 0};
217 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
219 TRACE("Could not get IDispatch\n");
223 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
224 DISPATCH_PROPERTYGET, &dispparams, res, NULL, NULL);
226 IDispatch_Release(disp);
231 static HRESULT on_offlineconnected_change(WebBrowser *This)
235 get_client_disp_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
237 if(V_VT(&offline) == VT_BOOL)
238 IWebBrowser2_put_Offline(&This->IWebBrowser2_iface, V_BOOL(&offline));
239 else if(V_VT(&offline) != VT_EMPTY)
240 WARN("wrong V_VT(silent) %d\n", V_VT(&offline));
245 static HRESULT on_silent_change(WebBrowser *This)
249 get_client_disp_property(This->client, DISPID_AMBIENT_SILENT, &silent);
251 if(V_VT(&silent) == VT_BOOL)
252 IWebBrowser2_put_Silent(&This->IWebBrowser2_iface, V_BOOL(&silent));
253 else if(V_VT(&silent) != VT_EMPTY)
254 WARN("wrong V_VT(silent) %d\n", V_VT(&silent));
259 static void release_client_site(WebBrowser *This)
261 release_dochost_client(&This->doc_host);
263 if(This->shell_embedding_hwnd) {
264 DestroyWindow(This->shell_embedding_hwnd);
265 This->shell_embedding_hwnd = NULL;
269 IOleInPlaceSite_Release(This->inplace);
270 This->inplace = NULL;
273 if(This->container) {
274 IOleContainer_Release(This->container);
275 This->container = NULL;
279 IOleInPlaceUIWindow_Release(This->uiwindow);
280 This->uiwindow = NULL;
284 IOleClientSite_Release(This->client);
289 /**********************************************************************
290 * Implement the IOleObject interface for the WebBrowser control
293 static inline WebBrowser *impl_from_IOleObject(IOleObject *iface)
295 return CONTAINING_RECORD(iface, WebBrowser, IOleObject_iface);
298 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
300 WebBrowser *This = impl_from_IOleObject(iface);
301 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
304 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
306 WebBrowser *This = impl_from_IOleObject(iface);
307 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
310 static ULONG WINAPI OleObject_Release(IOleObject *iface)
312 WebBrowser *This = impl_from_IOleObject(iface);
313 return IWebBrowser_Release(&This->IWebBrowser2_iface);
316 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
318 WebBrowser *This = impl_from_IOleObject(iface);
319 IDocHostUIHandler *hostui;
320 IOleContainer *container;
324 TRACE("(%p)->(%p)\n", This, pClientSite);
326 if(This->client == pClientSite)
329 release_client_site(This);
332 if(This->doc_host.document)
333 deactivate_document(&This->doc_host);
337 IOleClientSite_AddRef(pClientSite);
338 This->client = pClientSite;
340 hres = IOleClientSite_QueryInterface(This->client, &IID_IDispatch,
343 This->doc_host.client_disp = disp;
345 hres = IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
348 This->doc_host.hostui = hostui;
350 hres = IOleClientSite_GetContainer(This->client, &container);
351 if(SUCCEEDED(hres)) {
352 ITargetContainer *target_container;
354 hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
355 (void**)&target_container);
356 if(SUCCEEDED(hres)) {
357 FIXME("Unsupported ITargetContainer\n");
358 ITargetContainer_Release(target_container);
361 IOleContainer_Release(container);
364 create_shell_embedding_hwnd(This);
366 on_offlineconnected_change(This);
367 on_silent_change(This);
372 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
374 WebBrowser *This = impl_from_IOleObject(iface);
376 TRACE("(%p)->(%p)\n", This, ppClientSite);
382 IOleClientSite_AddRef(This->client);
383 *ppClientSite = This->client;
388 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
389 LPCOLESTR szContainerObj)
391 WebBrowser *This = impl_from_IOleObject(iface);
393 TRACE("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
395 /* We have nothing to do here. */
399 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
401 WebBrowser *This = impl_from_IOleObject(iface);
402 FIXME("(%p)->(%d)\n", This, dwSaveOption);
406 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
408 WebBrowser *This = impl_from_IOleObject(iface);
409 FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
413 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
414 DWORD dwWhichMoniker, LPMONIKER *ppmk)
416 WebBrowser *This = impl_from_IOleObject(iface);
417 FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
421 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
422 BOOL fCreation, DWORD dwReserved)
424 WebBrowser *This = impl_from_IOleObject(iface);
425 FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
429 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
430 LPDATAOBJECT *ppDataObject)
432 WebBrowser *This = impl_from_IOleObject(iface);
433 FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
437 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
438 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
440 WebBrowser *This = impl_from_IOleObject(iface);
442 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
448 TRACE("OLEIVERB_SHOW\n");
449 return activate_ui(This, pActiveSite);
450 case OLEIVERB_UIACTIVATE:
451 TRACE("OLEIVERB_UIACTIVATE\n");
452 return activate_ui(This, pActiveSite);
453 case OLEIVERB_INPLACEACTIVATE:
454 TRACE("OLEIVERB_INPLACEACTIVATE\n");
455 return activate_inplace(This, pActiveSite);
457 TRACE("OLEIVERB_HIDE\n");
458 if(This->shell_embedding_hwnd)
459 ShowWindow(This->shell_embedding_hwnd, SW_HIDE);
462 FIXME("stub for %d\n", iVerb);
469 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
471 WebBrowser *This = impl_from_IOleObject(iface);
472 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
473 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
476 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
478 WebBrowser *This = impl_from_IOleObject(iface);
479 FIXME("(%p)\n", This);
483 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
485 WebBrowser *This = impl_from_IOleObject(iface);
486 FIXME("(%p)\n", This);
490 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
492 WebBrowser *This = impl_from_IOleObject(iface);
493 FIXME("(%p)->(%p)\n", This, pClsid);
497 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
498 LPOLESTR* pszUserType)
500 WebBrowser *This = impl_from_IOleObject(iface);
501 TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
502 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
505 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
507 WebBrowser *This = impl_from_IOleObject(iface);
509 TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
511 /* Tests show that dwDrawAspect is ignored */
512 This->extent = *psizel;
516 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
518 WebBrowser *This = impl_from_IOleObject(iface);
520 TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
522 /* Tests show that dwDrawAspect is ignored */
523 *psizel = This->extent;
527 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
528 DWORD* pdwConnection)
530 WebBrowser *This = impl_from_IOleObject(iface);
531 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
535 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
537 WebBrowser *This = impl_from_IOleObject(iface);
538 FIXME("(%p)->(%d)\n", This, dwConnection);
542 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
544 WebBrowser *This = impl_from_IOleObject(iface);
545 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
549 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
551 WebBrowser *This = impl_from_IOleObject(iface);
553 TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
555 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
556 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
561 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
563 WebBrowser *This = impl_from_IOleObject(iface);
564 FIXME("(%p)->(%p)\n", This, pLogpal);
568 static const IOleObjectVtbl OleObjectVtbl =
570 OleObject_QueryInterface,
573 OleObject_SetClientSite,
574 OleObject_GetClientSite,
575 OleObject_SetHostNames,
577 OleObject_SetMoniker,
578 OleObject_GetMoniker,
579 OleObject_InitFromData,
580 OleObject_GetClipboardData,
584 OleObject_IsUpToDate,
585 OleObject_GetUserClassID,
586 OleObject_GetUserType,
591 OleObject_EnumAdvise,
592 OleObject_GetMiscStatus,
593 OleObject_SetColorScheme
596 /**********************************************************************
597 * Implement the IOleInPlaceObject interface
600 static inline WebBrowser *impl_from_IOleInPlaceObject(IOleInPlaceObject *iface)
602 return CONTAINING_RECORD(iface, WebBrowser, IOleInPlaceObject_iface);
605 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
606 REFIID riid, LPVOID *ppobj)
608 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
609 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
612 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
614 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
615 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
618 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
620 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
621 return IWebBrowser_Release(&This->IWebBrowser2_iface);
624 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
626 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
628 TRACE("(%p)->(%p)\n", This, phwnd);
630 *phwnd = This->shell_embedding_hwnd;
634 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
637 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
638 FIXME("(%p)->(%x)\n", This, fEnterMode);
642 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
644 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
645 FIXME("(%p)\n", This);
648 IOleInPlaceSite_Release(This->inplace);
649 This->inplace = NULL;
655 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
657 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
658 FIXME("(%p)\n", This);
662 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
663 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
665 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
667 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
669 This->pos_rect = *lprcPosRect;
672 This->clip_rect = *lprcClipRect;
674 if(This->shell_embedding_hwnd) {
675 SetWindowPos(This->shell_embedding_hwnd, NULL,
676 lprcPosRect->left, lprcPosRect->top,
677 lprcPosRect->right-lprcPosRect->left,
678 lprcPosRect->bottom-lprcPosRect->top,
679 SWP_NOZORDER | SWP_NOACTIVATE);
685 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
687 WebBrowser *This = impl_from_IOleInPlaceObject(iface);
688 FIXME("(%p)\n", This);
692 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
694 OleInPlaceObject_QueryInterface,
695 OleInPlaceObject_AddRef,
696 OleInPlaceObject_Release,
697 OleInPlaceObject_GetWindow,
698 OleInPlaceObject_ContextSensitiveHelp,
699 OleInPlaceObject_InPlaceDeactivate,
700 OleInPlaceObject_UIDeactivate,
701 OleInPlaceObject_SetObjectRects,
702 OleInPlaceObject_ReactivateAndUndo
705 /**********************************************************************
706 * Implement the IOleControl interface
709 static inline WebBrowser *impl_from_IOleControl(IOleControl *iface)
711 return CONTAINING_RECORD(iface, WebBrowser, IOleControl_iface);
714 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
715 REFIID riid, LPVOID *ppobj)
717 WebBrowser *This = impl_from_IOleControl(iface);
718 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppobj);
721 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
723 WebBrowser *This = impl_from_IOleControl(iface);
724 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
727 static ULONG WINAPI OleControl_Release(IOleControl *iface)
729 WebBrowser *This = impl_from_IOleControl(iface);
730 return IWebBrowser_Release(&This->IWebBrowser2_iface);
733 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
735 WebBrowser *This = impl_from_IOleControl(iface);
737 TRACE("(%p)->(%p)\n", This, pCI);
739 /* Tests show that this function should be not implemented */
743 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
745 WebBrowser *This = impl_from_IOleControl(iface);
746 FIXME("(%p)->(%p)\n", This, pMsg);
750 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
752 WebBrowser *This = impl_from_IOleControl(iface);
754 TRACE("(%p)->(%d)\n", This, dispID);
758 /* Unknown means multiple properties changed, so check them all.
759 * BUT the Webbrowser OleControl object doesn't appear to do this.
762 case DISPID_AMBIENT_DLCONTROL:
764 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
765 return on_offlineconnected_change(This);
766 case DISPID_AMBIENT_SILENT:
767 return on_silent_change(This);
770 FIXME("Unknown dispID %d\n", dispID);
774 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
776 WebBrowser *This = impl_from_IOleControl(iface);
777 FIXME("(%p)->(%x)\n", This, bFreeze);
781 static const IOleControlVtbl OleControlVtbl =
783 OleControl_QueryInterface,
786 OleControl_GetControlInfo,
787 OleControl_OnMnemonic,
788 OleControl_OnAmbientPropertyChange,
789 OleControl_FreezeEvents
792 static inline WebBrowser *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
794 return CONTAINING_RECORD(iface, WebBrowser, IOleInPlaceActiveObject_iface);
797 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
798 REFIID riid, void **ppv)
800 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
801 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
804 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
806 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
807 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
810 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
812 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
813 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
816 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
819 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
820 return IOleInPlaceObject_GetWindow(&This->IOleInPlaceObject_iface, phwnd);
823 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
826 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
827 return IOleInPlaceObject_ContextSensitiveHelp(&This->IOleInPlaceObject_iface, fEnterMode);
830 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
833 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
834 IOleInPlaceActiveObject *activeobj;
835 HRESULT hr = S_FALSE;
837 TRACE("(%p)->(%p)\n", This, lpmsg);
839 if(This->doc_host.document) {
840 if(SUCCEEDED(IUnknown_QueryInterface(This->doc_host.document,
841 &IID_IOleInPlaceActiveObject,
842 (void**)&activeobj))) {
843 hr = IOleInPlaceActiveObject_TranslateAccelerator(activeobj, lpmsg);
844 IOleInPlaceActiveObject_Release(activeobj);
854 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
857 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
858 FIXME("(%p)->(%x)\n", This, fActivate);
862 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
865 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
866 FIXME("(%p)->(%x)\n", This, fActivate);
870 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
871 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
873 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
874 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
878 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
881 WebBrowser *This = impl_from_IOleInPlaceActiveObject(iface);
882 FIXME("(%p)->(%x)\n", This, fEnable);
886 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
887 InPlaceActiveObject_QueryInterface,
888 InPlaceActiveObject_AddRef,
889 InPlaceActiveObject_Release,
890 InPlaceActiveObject_GetWindow,
891 InPlaceActiveObject_ContextSensitiveHelp,
892 InPlaceActiveObject_TranslateAccelerator,
893 InPlaceActiveObject_OnFrameWindowActivate,
894 InPlaceActiveObject_OnDocWindowActivate,
895 InPlaceActiveObject_ResizeBorder,
896 InPlaceActiveObject_EnableModeless
899 static inline WebBrowser *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
901 return CONTAINING_RECORD(iface, WebBrowser, IOleCommandTarget_iface);
904 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
905 REFIID riid, void **ppv)
907 WebBrowser *This = impl_from_IOleCommandTarget(iface);
908 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
911 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
913 WebBrowser *This = impl_from_IOleCommandTarget(iface);
914 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
917 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
919 WebBrowser *This = impl_from_IOleCommandTarget(iface);
920 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
923 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
924 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
926 WebBrowser *This = impl_from_IOleCommandTarget(iface);
927 IOleCommandTarget *cmdtrg;
930 TRACE("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
933 if(!This->doc_host.document)
936 /* NOTE: There are probably some commands that we should handle here
937 * instead of forwarding to document object. */
939 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (void**)&cmdtrg);
943 hres = IOleCommandTarget_QueryStatus(cmdtrg, pguidCmdGroup, cCmds, prgCmds, pCmdText);
944 IOleCommandTarget_Release(cmdtrg);
949 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
950 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
953 WebBrowser *This = impl_from_IOleCommandTarget(iface);
954 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
955 nCmdexecopt, pvaIn, pvaOut);
959 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
960 WBOleCommandTarget_QueryInterface,
961 WBOleCommandTarget_AddRef,
962 WBOleCommandTarget_Release,
963 WBOleCommandTarget_QueryStatus,
964 WBOleCommandTarget_Exec
967 void WebBrowser_OleObject_Init(WebBrowser *This)
973 /* default aspect ratio is 96dpi / 96dpi */
975 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
976 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
979 This->IOleObject_iface.lpVtbl = &OleObjectVtbl;
980 This->IOleInPlaceObject_iface.lpVtbl = &OleInPlaceObjectVtbl;
981 This->IOleControl_iface.lpVtbl = &OleControlVtbl;
982 This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
983 This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
985 /* Default size is 50x20 pixels, in himetric units */
986 This->extent.cx = MulDiv( 50, 2540, dpi_x );
987 This->extent.cy = MulDiv( 20, 2540, dpi_y );
990 void WebBrowser_OleObject_Destroy(WebBrowser *This)
992 release_client_site(This);