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, ACTIVEOBJ(This), wszitem);
195 IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, ACTIVEOBJ(This), 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(WEBBROWSER2(This), 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(WEBBROWSER2(This), V_BOOL(&silent));
252 else if(V_VT(&silent) != VT_EMPTY)
253 WARN("wrong V_VT(silent) %d\n", V_VT(&silent));
258 /**********************************************************************
259 * Implement the IOleObject interface for the WebBrowser control
262 #define OLEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
264 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
266 WebBrowser *This = OLEOBJ_THIS(iface);
267 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppv);
270 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
272 WebBrowser *This = OLEOBJ_THIS(iface);
273 return IWebBrowser_AddRef(WEBBROWSER(This));
276 static ULONG WINAPI OleObject_Release(IOleObject *iface)
278 WebBrowser *This = OLEOBJ_THIS(iface);
279 return IWebBrowser_Release(WEBBROWSER(This));
282 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE pClientSite)
284 WebBrowser *This = OLEOBJ_THIS(iface);
285 IOleContainer *container;
288 TRACE("(%p)->(%p)\n", This, pClientSite);
290 if(This->client == pClientSite)
293 if(This->doc_host.hwnd) {
294 DestroyWindow(This->doc_host.hwnd);
295 This->doc_host.hwnd = NULL;
297 if(This->shell_embedding_hwnd) {
298 DestroyWindow(This->shell_embedding_hwnd);
299 This->shell_embedding_hwnd = NULL;
303 IOleInPlaceSite_Release(This->inplace);
304 This->inplace = NULL;
307 if(This->doc_host.hostui) {
308 IDocHostUIHandler_Release(This->doc_host.hostui);
309 This->doc_host.hostui = NULL;
313 IOleClientSite_Release(This->client);
315 This->client = pClientSite;
318 if(This->doc_host.document)
319 deactivate_document(&This->doc_host);
323 IOleClientSite_AddRef(pClientSite);
325 IOleClientSite_QueryInterface(This->client, &IID_IDispatch,
326 (void**)&This->doc_host.client_disp);
328 IOleClientSite_QueryInterface(This->client, &IID_IDocHostUIHandler,
329 (void**)&This->doc_host.hostui);
331 hres = IOleClientSite_GetContainer(This->client, &container);
332 if(SUCCEEDED(hres)) {
333 ITargetContainer *target_container;
335 hres = IOleContainer_QueryInterface(container, &IID_ITargetContainer,
336 (void**)&target_container);
337 if(SUCCEEDED(hres)) {
338 FIXME("Unsupported ITargetContainer\n");
339 ITargetContainer_Release(target_container);
342 IOleContainer_Release(container);
345 create_shell_embedding_hwnd(This);
347 on_offlineconnected_change(This);
348 on_silent_change(This);
353 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, LPOLECLIENTSITE *ppClientSite)
355 WebBrowser *This = OLEOBJ_THIS(iface);
357 TRACE("(%p)->(%p)\n", This, ppClientSite);
363 IOleClientSite_AddRef(This->client);
364 *ppClientSite = This->client;
369 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp,
370 LPCOLESTR szContainerObj)
372 WebBrowser *This = OLEOBJ_THIS(iface);
374 TRACE("(%p)->(%s, %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
376 /* We have nothing to do here. */
380 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
382 WebBrowser *This = OLEOBJ_THIS(iface);
383 FIXME("(%p)->(%d)\n", This, dwSaveOption);
387 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
389 WebBrowser *This = OLEOBJ_THIS(iface);
390 FIXME("(%p)->(%d, %p)\n", This, dwWhichMoniker, pmk);
394 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign,
395 DWORD dwWhichMoniker, LPMONIKER *ppmk)
397 WebBrowser *This = OLEOBJ_THIS(iface);
398 FIXME("(%p)->(%d, %d, %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
402 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, LPDATAOBJECT pDataObject,
403 BOOL fCreation, DWORD dwReserved)
405 WebBrowser *This = OLEOBJ_THIS(iface);
406 FIXME("(%p)->(%p, %d, %d)\n", This, pDataObject, fCreation, dwReserved);
410 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved,
411 LPDATAOBJECT *ppDataObject)
413 WebBrowser *This = OLEOBJ_THIS(iface);
414 FIXME("(%p)->(%d, %p)\n", This, dwReserved, ppDataObject);
418 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tagMSG* lpmsg,
419 LPOLECLIENTSITE pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
421 WebBrowser *This = OLEOBJ_THIS(iface);
423 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
429 TRACE("OLEIVERB_SHOW\n");
430 return activate_ui(This, pActiveSite);
431 case OLEIVERB_UIACTIVATE:
432 TRACE("OLEIVERB_UIACTIVATE\n");
433 return activate_ui(This, pActiveSite);
434 case OLEIVERB_INPLACEACTIVATE:
435 TRACE("OLEIVERB_INPLACEACTIVATE\n");
436 return activate_inplace(This, pActiveSite);
438 TRACE("OLEIVERB_HIDE\n");
439 if(This->shell_embedding_hwnd)
440 ShowWindow(This->shell_embedding_hwnd, SW_HIDE);
443 FIXME("stub for %d\n", iVerb);
450 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
452 WebBrowser *This = OLEOBJ_THIS(iface);
453 TRACE("(%p)->(%p)\n", This, ppEnumOleVerb);
454 return OleRegEnumVerbs(&CLSID_WebBrowser, ppEnumOleVerb);
457 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
459 WebBrowser *This = OLEOBJ_THIS(iface);
460 FIXME("(%p)\n", This);
464 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
466 WebBrowser *This = OLEOBJ_THIS(iface);
467 FIXME("(%p)\n", This);
471 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID* pClsid)
473 WebBrowser *This = OLEOBJ_THIS(iface);
474 FIXME("(%p)->(%p)\n", This, pClsid);
478 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType,
479 LPOLESTR* pszUserType)
481 WebBrowser *This = OLEOBJ_THIS(iface);
482 TRACE("(%p, %d, %p)\n", This, dwFormOfType, pszUserType);
483 return OleRegGetUserType(&CLSID_WebBrowser, dwFormOfType, pszUserType);
486 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
488 WebBrowser *This = OLEOBJ_THIS(iface);
490 TRACE("(%p)->(%x %p)\n", This, dwDrawAspect, psizel);
492 /* Tests show that dwDrawAspect is ignored */
493 This->extent = *psizel;
497 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
499 WebBrowser *This = OLEOBJ_THIS(iface);
501 TRACE("(%p)->(%x, %p)\n", This, dwDrawAspect, psizel);
503 /* Tests show that dwDrawAspect is ignored */
504 *psizel = This->extent;
508 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink,
509 DWORD* pdwConnection)
511 WebBrowser *This = OLEOBJ_THIS(iface);
512 FIXME("(%p)->(%p, %p)\n", This, pAdvSink, pdwConnection);
516 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
518 WebBrowser *This = OLEOBJ_THIS(iface);
519 FIXME("(%p)->(%d)\n", This, dwConnection);
523 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
525 WebBrowser *This = OLEOBJ_THIS(iface);
526 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
530 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
532 WebBrowser *This = OLEOBJ_THIS(iface);
534 TRACE("(%p)->(%x, %p)\n", This, dwAspect, pdwStatus);
536 *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
537 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
542 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE* pLogpal)
544 WebBrowser *This = OLEOBJ_THIS(iface);
545 FIXME("(%p)->(%p)\n", This, pLogpal);
551 static const IOleObjectVtbl OleObjectVtbl =
553 OleObject_QueryInterface,
556 OleObject_SetClientSite,
557 OleObject_GetClientSite,
558 OleObject_SetHostNames,
560 OleObject_SetMoniker,
561 OleObject_GetMoniker,
562 OleObject_InitFromData,
563 OleObject_GetClipboardData,
567 OleObject_IsUpToDate,
568 OleObject_GetUserClassID,
569 OleObject_GetUserType,
574 OleObject_EnumAdvise,
575 OleObject_GetMiscStatus,
576 OleObject_SetColorScheme
579 /**********************************************************************
580 * Implement the IOleInPlaceObject interface
583 #define INPLACEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceObject, iface)
585 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObject *iface,
586 REFIID riid, LPVOID *ppobj)
588 WebBrowser *This = INPLACEOBJ_THIS(iface);
589 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
592 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObject *iface)
594 WebBrowser *This = INPLACEOBJ_THIS(iface);
595 return IWebBrowser_AddRef(WEBBROWSER(This));
598 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObject *iface)
600 WebBrowser *This = INPLACEOBJ_THIS(iface);
601 return IWebBrowser_Release(WEBBROWSER(This));
604 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObject *iface, HWND* phwnd)
606 WebBrowser *This = INPLACEOBJ_THIS(iface);
608 TRACE("(%p)->(%p)\n", This, phwnd);
610 *phwnd = This->shell_embedding_hwnd;
614 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject *iface,
617 WebBrowser *This = INPLACEOBJ_THIS(iface);
618 FIXME("(%p)->(%x)\n", This, fEnterMode);
622 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject *iface)
624 WebBrowser *This = INPLACEOBJ_THIS(iface);
625 FIXME("(%p)\n", This);
629 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObject *iface)
631 WebBrowser *This = INPLACEOBJ_THIS(iface);
632 FIXME("(%p)\n", This);
636 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
637 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
639 WebBrowser *This = INPLACEOBJ_THIS(iface);
641 TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
643 This->pos_rect = *lprcPosRect;
646 This->clip_rect = *lprcClipRect;
648 if(This->shell_embedding_hwnd) {
649 SetWindowPos(This->shell_embedding_hwnd, NULL,
650 lprcPosRect->left, lprcPosRect->top,
651 lprcPosRect->right-lprcPosRect->left,
652 lprcPosRect->bottom-lprcPosRect->top,
653 SWP_NOZORDER | SWP_NOACTIVATE);
659 static HRESULT WINAPI OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject *iface)
661 WebBrowser *This = INPLACEOBJ_THIS(iface);
662 FIXME("(%p)\n", This);
666 #undef INPLACEOBJ_THIS
668 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl =
670 OleInPlaceObject_QueryInterface,
671 OleInPlaceObject_AddRef,
672 OleInPlaceObject_Release,
673 OleInPlaceObject_GetWindow,
674 OleInPlaceObject_ContextSensitiveHelp,
675 OleInPlaceObject_InPlaceDeactivate,
676 OleInPlaceObject_UIDeactivate,
677 OleInPlaceObject_SetObjectRects,
678 OleInPlaceObject_ReactivateAndUndo
681 /**********************************************************************
682 * Implement the IOleControl interface
685 #define CONTROL_THIS(iface) DEFINE_THIS(WebBrowser, OleControl, iface)
687 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface,
688 REFIID riid, LPVOID *ppobj)
690 WebBrowser *This = CONTROL_THIS(iface);
691 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
694 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
696 WebBrowser *This = CONTROL_THIS(iface);
697 return IWebBrowser_AddRef(WEBBROWSER(This));
700 static ULONG WINAPI OleControl_Release(IOleControl *iface)
702 WebBrowser *This = CONTROL_THIS(iface);
703 return IWebBrowser_Release(WEBBROWSER(This));
706 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, LPCONTROLINFO pCI)
708 WebBrowser *This = CONTROL_THIS(iface);
710 TRACE("(%p)->(%p)\n", This, pCI);
712 /* Tests show that this function should be not implemented */
716 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, struct tagMSG *pMsg)
718 WebBrowser *This = CONTROL_THIS(iface);
719 FIXME("(%p)->(%p)\n", This, pMsg);
723 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
725 WebBrowser *This = CONTROL_THIS(iface);
727 TRACE("(%p)->(%d)\n", This, dispID);
731 /* Unknown means multiple properties changed, so check them all.
732 * BUT the Webbrowser OleControl object doesn't appear to do this.
735 case DISPID_AMBIENT_DLCONTROL:
737 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
738 return on_offlineconnected_change(This);
739 case DISPID_AMBIENT_SILENT:
740 return on_silent_change(This);
743 FIXME("Unknown dispID %d\n", dispID);
747 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
749 WebBrowser *This = CONTROL_THIS(iface);
750 FIXME("(%p)->(%x)\n", This, bFreeze);
756 static const IOleControlVtbl OleControlVtbl =
758 OleControl_QueryInterface,
761 OleControl_GetControlInfo,
762 OleControl_OnMnemonic,
763 OleControl_OnAmbientPropertyChange,
764 OleControl_FreezeEvents
767 #define ACTIVEOBJ_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceActiveObject, iface)
769 static HRESULT WINAPI InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface,
770 REFIID riid, void **ppv)
772 WebBrowser *This = ACTIVEOBJ_THIS(iface);
773 return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
776 static ULONG WINAPI InPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
778 WebBrowser *This = ACTIVEOBJ_THIS(iface);
779 return IWebBrowser2_AddRef(WEBBROWSER2(This));
782 static ULONG WINAPI InPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
784 WebBrowser *This = ACTIVEOBJ_THIS(iface);
785 return IWebBrowser2_Release(WEBBROWSER2(This));
788 static HRESULT WINAPI InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface,
791 WebBrowser *This = ACTIVEOBJ_THIS(iface);
792 return IOleInPlaceObject_GetWindow(INPLACEOBJ(This), phwnd);
795 static HRESULT WINAPI InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface,
798 WebBrowser *This = ACTIVEOBJ_THIS(iface);
799 return IOleInPlaceObject_ContextSensitiveHelp(INPLACEOBJ(This), fEnterMode);
802 static HRESULT WINAPI InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface,
805 WebBrowser *This = ACTIVEOBJ_THIS(iface);
806 FIXME("(%p)->(%p)\n", This, lpmsg);
810 static HRESULT WINAPI InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
813 WebBrowser *This = ACTIVEOBJ_THIS(iface);
814 FIXME("(%p)->(%x)\n", This, fActivate);
818 static HRESULT WINAPI InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface,
821 WebBrowser *This = ACTIVEOBJ_THIS(iface);
822 FIXME("(%p)->(%x)\n", This, fActivate);
826 static HRESULT WINAPI InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface,
827 LPCRECT lprcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
829 WebBrowser *This = ACTIVEOBJ_THIS(iface);
830 FIXME("(%p)->(%p %p %x)\n", This, lprcBorder, pUIWindow, fFrameWindow);
834 static HRESULT WINAPI InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface,
837 WebBrowser *This = ACTIVEOBJ_THIS(iface);
838 FIXME("(%p)->(%x)\n", This, fEnable);
842 #undef ACTIVEOBJ_THIS
844 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
845 InPlaceActiveObject_QueryInterface,
846 InPlaceActiveObject_AddRef,
847 InPlaceActiveObject_Release,
848 InPlaceActiveObject_GetWindow,
849 InPlaceActiveObject_ContextSensitiveHelp,
850 InPlaceActiveObject_TranslateAccelerator,
851 InPlaceActiveObject_OnFrameWindowActivate,
852 InPlaceActiveObject_OnDocWindowActivate,
853 InPlaceActiveObject_ResizeBorder,
854 InPlaceActiveObject_EnableModeless
857 #define OLECMD_THIS(iface) DEFINE_THIS(WebBrowser, OleCommandTarget, iface)
859 static HRESULT WINAPI WBOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
860 REFIID riid, void **ppv)
862 WebBrowser *This = OLECMD_THIS(iface);
863 return IWebBrowser2_QueryInterface(WEBBROWSER(This), riid, ppv);
866 static ULONG WINAPI WBOleCommandTarget_AddRef(IOleCommandTarget *iface)
868 WebBrowser *This = OLECMD_THIS(iface);
869 return IWebBrowser2_AddRef(WEBBROWSER(This));
872 static ULONG WINAPI WBOleCommandTarget_Release(IOleCommandTarget *iface)
874 WebBrowser *This = OLECMD_THIS(iface);
875 return IWebBrowser2_Release(WEBBROWSER(This));
878 static HRESULT WINAPI WBOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
879 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
881 WebBrowser *This = OLECMD_THIS(iface);
882 IOleCommandTarget *cmdtrg;
885 TRACE("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
888 if(!This->doc_host.document)
891 /* NOTE: There are probably some commands that we should handle here
892 * instead of forwarding to document object. */
894 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (void**)&cmdtrg);
898 hres = IOleCommandTarget_QueryStatus(cmdtrg, pguidCmdGroup, cCmds, prgCmds, pCmdText);
899 IOleCommandTarget_Release(cmdtrg);
904 static HRESULT WINAPI WBOleCommandTarget_Exec(IOleCommandTarget *iface,
905 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
908 WebBrowser *This = OLECMD_THIS(iface);
909 FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
910 nCmdexecopt, pvaIn, pvaOut);
916 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
917 WBOleCommandTarget_QueryInterface,
918 WBOleCommandTarget_AddRef,
919 WBOleCommandTarget_Release,
920 WBOleCommandTarget_QueryStatus,
921 WBOleCommandTarget_Exec
924 void WebBrowser_OleObject_Init(WebBrowser *This)
930 /* default aspect ratio is 96dpi / 96dpi */
932 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
933 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
936 This->lpOleObjectVtbl = &OleObjectVtbl;
937 This->lpOleInPlaceObjectVtbl = &OleInPlaceObjectVtbl;
938 This->lpOleControlVtbl = &OleControlVtbl;
939 This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
940 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
943 This->inplace = NULL;
944 This->container = NULL;
945 This->frame_hwnd = NULL;
946 This->uiwindow = NULL;
947 This->shell_embedding_hwnd = NULL;
949 memset(&This->pos_rect, 0, sizeof(RECT));
950 memset(&This->clip_rect, 0, sizeof(RECT));
951 memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
953 /* Default size is 50x20 pixels, in himetric units */
954 This->extent.cx = MulDiv( 50, 2540, dpi_x );
955 This->extent.cy = MulDiv( 20, 2540, dpi_y );
958 void WebBrowser_OleObject_Destroy(WebBrowser *This)
961 IOleObject_SetClientSite(OLEOBJ(This), NULL);
963 IOleContainer_Release(This->container);
965 IOleInPlaceUIWindow_Release(This->uiwindow);