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
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
39 HWND WINAPI
SHSetParentHwnd(HWND hWnd
, HWND hWndParent
);
41 static ATOM shell_embedding_atom
= 0;
43 static LRESULT
resize_window(WebBrowser
*This
, LONG width
, LONG height
)
45 if(This
->doc_host
.hwnd
)
46 SetWindowPos(This
->doc_host
.hwnd
, NULL
, 0, 0, width
, height
,
47 SWP_NOZORDER
| SWP_NOACTIVATE
);
52 static LRESULT WINAPI
shell_embedding_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
56 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
58 if(msg
== WM_CREATE
) {
59 This
= *(WebBrowser
**)lParam
;
60 SetPropW(hwnd
, wszTHIS
, This
);
62 This
= GetPropW(hwnd
, wszTHIS
);
67 return resize_window(This
, LOWORD(lParam
), HIWORD(lParam
));
69 return process_dochost_tasks(&This
->doc_host
);
72 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
75 static void create_shell_embedding_hwnd(WebBrowser
*This
)
77 IOleInPlaceSite
*inplace
;
81 static const WCHAR wszShellEmbedding
[] =
82 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
84 if(!shell_embedding_atom
) {
85 static WNDCLASSEXW wndclass
= {
89 0, 0 /* native uses 8 */, NULL
, NULL
, NULL
,
90 (HBRUSH
)(COLOR_WINDOW
+ 1), NULL
,
94 wndclass
.hInstance
= ieframe_instance
;
96 RegisterClassExW(&wndclass
);
99 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleInPlaceSite
, (void**)&inplace
);
100 if(SUCCEEDED(hres
)) {
101 IOleInPlaceSite_GetWindow(inplace
, &parent
);
102 IOleInPlaceSite_Release(inplace
);
105 This
->doc_host
.frame_hwnd
= This
->shell_embedding_hwnd
= CreateWindowExW(
107 wszShellEmbedding
, wszShellEmbedding
,
108 WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
109 | (parent
? WS_CHILD
| WS_TABSTOP
: WS_POPUP
| WS_MAXIMIZEBOX
),
111 NULL
, ieframe_instance
, This
);
113 TRACE("parent=%p hwnd=%p\n", parent
, This
->shell_embedding_hwnd
);
116 static HRESULT
activate_inplace(WebBrowser
*This
, IOleClientSite
*active_site
)
127 hres
= IOleClientSite_QueryInterface(active_site
, &IID_IOleInPlaceSite
,
128 (void**)&This
->inplace
);
130 WARN("Could not get IOleInPlaceSite\n");
134 hres
= IOleInPlaceSite_CanInPlaceActivate(This
->inplace
);
136 WARN("CanInPlaceActivate returned: %08x\n", hres
);
137 IOleInPlaceSite_Release(This
->inplace
);
141 hres
= IOleInPlaceSite_GetWindow(This
->inplace
, &parent_hwnd
);
143 SHSetParentHwnd(This
->shell_embedding_hwnd
, parent_hwnd
);
145 IOleInPlaceSite_OnInPlaceActivate(This
->inplace
);
147 This
->frameinfo
.cb
= sizeof(OLEINPLACEFRAMEINFO
);
148 IOleInPlaceSite_GetWindowContext(This
->inplace
, &This
->doc_host
.frame
, &This
->uiwindow
,
149 &This
->pos_rect
, &This
->clip_rect
,
152 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
153 This
->pos_rect
.left
, This
->pos_rect
.top
,
154 This
->pos_rect
.right
-This
->pos_rect
.left
,
155 This
->pos_rect
.bottom
-This
->pos_rect
.top
,
156 SWP_NOZORDER
| SWP_SHOWWINDOW
);
159 IOleContainer
*container
;
161 IOleClientSite_ShowObject(This
->client
);
163 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
164 if(SUCCEEDED(hres
)) {
166 IOleContainer_Release(This
->container
);
167 This
->container
= container
;
171 if(This
->doc_host
.frame
)
172 IOleInPlaceFrame_GetWindow(This
->doc_host
.frame
, &This
->frame_hwnd
);
177 static HRESULT
activate_ui(WebBrowser
*This
, IOleClientSite
*active_site
)
181 static const WCHAR wszitem
[] = {'i','t','e','m',0};
185 if(This
->shell_embedding_hwnd
)
186 ShowWindow(This
->shell_embedding_hwnd
, SW_SHOW
);
190 hres
= activate_inplace(This
, active_site
);
194 IOleInPlaceSite_OnUIActivate(This
->inplace
);
196 if(This
->doc_host
.frame
)
197 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
199 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
201 if(This
->doc_host
.frame
)
202 IOleInPlaceFrame_SetMenu(This
->doc_host
.frame
, NULL
, NULL
, This
->shell_embedding_hwnd
);
204 SetFocus(This
->shell_embedding_hwnd
);
209 static HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
211 IDispatch
*disp
= NULL
;
212 DISPPARAMS dispparams
= {NULL
, 0};
220 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
222 TRACE("Could not get IDispatch\n");
226 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
227 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, NULL
);
229 IDispatch_Release(disp
);
234 static HRESULT
on_offlineconnected_change(WebBrowser
*This
)
238 get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
240 if(V_VT(&offline
) == VT_BOOL
)
241 IWebBrowser2_put_Offline(&This
->IWebBrowser2_iface
, V_BOOL(&offline
));
242 else if(V_VT(&offline
) != VT_EMPTY
)
243 WARN("wrong V_VT(silent) %d\n", V_VT(&offline
));
248 static HRESULT
on_silent_change(WebBrowser
*This
)
252 get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
254 if(V_VT(&silent
) == VT_BOOL
)
255 IWebBrowser2_put_Silent(&This
->IWebBrowser2_iface
, V_BOOL(&silent
));
256 else if(V_VT(&silent
) != VT_EMPTY
)
257 WARN("wrong V_VT(silent) %d\n", V_VT(&silent
));
262 static void release_client_site(WebBrowser
*This
)
264 release_dochost_client(&This
->doc_host
);
266 if(This
->shell_embedding_hwnd
) {
267 DestroyWindow(This
->shell_embedding_hwnd
);
268 This
->shell_embedding_hwnd
= NULL
;
272 IOleInPlaceSite_Release(This
->inplace
);
273 This
->inplace
= NULL
;
276 if(This
->container
) {
277 IOleContainer_Release(This
->container
);
278 This
->container
= NULL
;
282 IOleInPlaceUIWindow_Release(This
->uiwindow
);
283 This
->uiwindow
= NULL
;
287 IOleClientSite_Release(This
->client
);
292 /**********************************************************************
293 * Implement the IOleObject interface for the WebBrowser control
296 static inline WebBrowser
*impl_from_IOleObject(IOleObject
*iface
)
298 return CONTAINING_RECORD(iface
, WebBrowser
, IOleObject_iface
);
301 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
303 WebBrowser
*This
= impl_from_IOleObject(iface
);
304 return IWebBrowser_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
307 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
309 WebBrowser
*This
= impl_from_IOleObject(iface
);
310 return IWebBrowser_AddRef(&This
->IWebBrowser2_iface
);
313 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
315 WebBrowser
*This
= impl_from_IOleObject(iface
);
316 return IWebBrowser_Release(&This
->IWebBrowser2_iface
);
319 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, LPOLECLIENTSITE pClientSite
)
321 WebBrowser
*This
= impl_from_IOleObject(iface
);
322 IDocHostUIHandler
*hostui
;
323 IOleContainer
*container
;
327 TRACE("(%p)->(%p)\n", This
, pClientSite
);
329 if(This
->client
== pClientSite
)
332 release_client_site(This
);
335 if(This
->doc_host
.document
)
336 deactivate_document(&This
->doc_host
);
340 IOleClientSite_AddRef(pClientSite
);
341 This
->client
= pClientSite
;
343 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDispatch
,
346 This
->doc_host
.client_disp
= disp
;
348 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
,
351 This
->doc_host
.hostui
= hostui
;
353 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
354 if(SUCCEEDED(hres
)) {
355 ITargetContainer
*target_container
;
357 hres
= IOleContainer_QueryInterface(container
, &IID_ITargetContainer
,
358 (void**)&target_container
);
359 if(SUCCEEDED(hres
)) {
360 FIXME("Unsupported ITargetContainer\n");
361 ITargetContainer_Release(target_container
);
364 IOleContainer_Release(container
);
367 create_shell_embedding_hwnd(This
);
369 on_offlineconnected_change(This
);
370 on_silent_change(This
);
375 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, LPOLECLIENTSITE
*ppClientSite
)
377 WebBrowser
*This
= impl_from_IOleObject(iface
);
379 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
385 IOleClientSite_AddRef(This
->client
);
386 *ppClientSite
= This
->client
;
391 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
,
392 LPCOLESTR szContainerObj
)
394 WebBrowser
*This
= impl_from_IOleObject(iface
);
396 TRACE("(%p)->(%s, %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
398 /* We have nothing to do here. */
402 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
404 WebBrowser
*This
= impl_from_IOleObject(iface
);
405 FIXME("(%p)->(%d)\n", This
, dwSaveOption
);
409 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
* pmk
)
411 WebBrowser
*This
= impl_from_IOleObject(iface
);
412 FIXME("(%p)->(%d, %p)\n", This
, dwWhichMoniker
, pmk
);
416 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
,
417 DWORD dwWhichMoniker
, LPMONIKER
*ppmk
)
419 WebBrowser
*This
= impl_from_IOleObject(iface
);
420 FIXME("(%p)->(%d, %d, %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
424 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, LPDATAOBJECT pDataObject
,
425 BOOL fCreation
, DWORD dwReserved
)
427 WebBrowser
*This
= impl_from_IOleObject(iface
);
428 FIXME("(%p)->(%p, %d, %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
432 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
,
433 LPDATAOBJECT
*ppDataObject
)
435 WebBrowser
*This
= impl_from_IOleObject(iface
);
436 FIXME("(%p)->(%d, %p)\n", This
, dwReserved
, ppDataObject
);
440 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, struct tagMSG
* lpmsg
,
441 LPOLECLIENTSITE pActiveSite
, LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
443 WebBrowser
*This
= impl_from_IOleObject(iface
);
445 TRACE("(%p)->(%d %p %p %d %p %p)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
,
451 TRACE("OLEIVERB_SHOW\n");
452 return activate_ui(This
, pActiveSite
);
453 case OLEIVERB_UIACTIVATE
:
454 TRACE("OLEIVERB_UIACTIVATE\n");
455 return activate_ui(This
, pActiveSite
);
456 case OLEIVERB_INPLACEACTIVATE
:
457 TRACE("OLEIVERB_INPLACEACTIVATE\n");
458 return activate_inplace(This
, pActiveSite
);
460 TRACE("OLEIVERB_HIDE\n");
461 if(This
->shell_embedding_hwnd
)
462 ShowWindow(This
->shell_embedding_hwnd
, SW_HIDE
);
465 FIXME("stub for %d\n", iVerb
);
472 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
474 WebBrowser
*This
= impl_from_IOleObject(iface
);
475 TRACE("(%p)->(%p)\n", This
, ppEnumOleVerb
);
476 return OleRegEnumVerbs(&CLSID_WebBrowser
, ppEnumOleVerb
);
479 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
481 WebBrowser
*This
= impl_from_IOleObject(iface
);
482 FIXME("(%p)\n", This
);
486 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
488 WebBrowser
*This
= impl_from_IOleObject(iface
);
489 FIXME("(%p)\n", This
);
493 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
* pClsid
)
495 WebBrowser
*This
= impl_from_IOleObject(iface
);
496 FIXME("(%p)->(%p)\n", This
, pClsid
);
500 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
,
501 LPOLESTR
* pszUserType
)
503 WebBrowser
*This
= impl_from_IOleObject(iface
);
504 TRACE("(%p, %d, %p)\n", This
, dwFormOfType
, pszUserType
);
505 return OleRegGetUserType(&CLSID_WebBrowser
, dwFormOfType
, pszUserType
);
508 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
510 WebBrowser
*This
= impl_from_IOleObject(iface
);
512 TRACE("(%p)->(%x %p)\n", This
, dwDrawAspect
, psizel
);
514 /* Tests show that dwDrawAspect is ignored */
515 This
->extent
= *psizel
;
519 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
521 WebBrowser
*This
= impl_from_IOleObject(iface
);
523 TRACE("(%p)->(%x, %p)\n", This
, dwDrawAspect
, psizel
);
525 /* Tests show that dwDrawAspect is ignored */
526 *psizel
= This
->extent
;
530 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
,
531 DWORD
* pdwConnection
)
533 WebBrowser
*This
= impl_from_IOleObject(iface
);
534 FIXME("(%p)->(%p, %p)\n", This
, pAdvSink
, pdwConnection
);
538 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
540 WebBrowser
*This
= impl_from_IOleObject(iface
);
541 FIXME("(%p)->(%d)\n", This
, dwConnection
);
545 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
547 WebBrowser
*This
= impl_from_IOleObject(iface
);
548 FIXME("(%p)->(%p)\n", This
, ppenumAdvise
);
552 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
554 WebBrowser
*This
= impl_from_IOleObject(iface
);
556 TRACE("(%p)->(%x, %p)\n", This
, dwAspect
, pdwStatus
);
558 *pdwStatus
= OLEMISC_SETCLIENTSITEFIRST
|OLEMISC_ACTIVATEWHENVISIBLE
|OLEMISC_INSIDEOUT
559 |OLEMISC_CANTLINKINSIDE
|OLEMISC_RECOMPOSEONRESIZE
;
564 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
* pLogpal
)
566 WebBrowser
*This
= impl_from_IOleObject(iface
);
567 FIXME("(%p)->(%p)\n", This
, pLogpal
);
571 static const IOleObjectVtbl OleObjectVtbl
=
573 OleObject_QueryInterface
,
576 OleObject_SetClientSite
,
577 OleObject_GetClientSite
,
578 OleObject_SetHostNames
,
580 OleObject_SetMoniker
,
581 OleObject_GetMoniker
,
582 OleObject_InitFromData
,
583 OleObject_GetClipboardData
,
587 OleObject_IsUpToDate
,
588 OleObject_GetUserClassID
,
589 OleObject_GetUserType
,
594 OleObject_EnumAdvise
,
595 OleObject_GetMiscStatus
,
596 OleObject_SetColorScheme
599 /**********************************************************************
600 * Implement the IOleInPlaceObject interface
603 static inline WebBrowser
*impl_from_IOleInPlaceObject(IOleInPlaceObject
*iface
)
605 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceObject_iface
);
608 static HRESULT WINAPI
OleInPlaceObject_QueryInterface(IOleInPlaceObject
*iface
,
609 REFIID riid
, LPVOID
*ppobj
)
611 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
612 return IWebBrowser_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
615 static ULONG WINAPI
OleInPlaceObject_AddRef(IOleInPlaceObject
*iface
)
617 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
618 return IWebBrowser_AddRef(&This
->IWebBrowser2_iface
);
621 static ULONG WINAPI
OleInPlaceObject_Release(IOleInPlaceObject
*iface
)
623 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
624 return IWebBrowser_Release(&This
->IWebBrowser2_iface
);
627 static HRESULT WINAPI
OleInPlaceObject_GetWindow(IOleInPlaceObject
*iface
, HWND
* phwnd
)
629 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
631 TRACE("(%p)->(%p)\n", This
, phwnd
);
633 *phwnd
= This
->shell_embedding_hwnd
;
637 static HRESULT WINAPI
OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject
*iface
,
640 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
641 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
645 static HRESULT WINAPI
OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject
*iface
)
647 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
648 FIXME("(%p)\n", This
);
651 IOleInPlaceSite_Release(This
->inplace
);
652 This
->inplace
= NULL
;
658 static HRESULT WINAPI
OleInPlaceObject_UIDeactivate(IOleInPlaceObject
*iface
)
660 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
661 FIXME("(%p)\n", This
);
665 static HRESULT WINAPI
OleInPlaceObject_SetObjectRects(IOleInPlaceObject
*iface
,
666 LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
668 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
670 TRACE("(%p)->(%p %p)\n", This
, lprcPosRect
, lprcClipRect
);
672 This
->pos_rect
= *lprcPosRect
;
675 This
->clip_rect
= *lprcClipRect
;
677 if(This
->shell_embedding_hwnd
) {
678 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
679 lprcPosRect
->left
, lprcPosRect
->top
,
680 lprcPosRect
->right
-lprcPosRect
->left
,
681 lprcPosRect
->bottom
-lprcPosRect
->top
,
682 SWP_NOZORDER
| SWP_NOACTIVATE
);
688 static HRESULT WINAPI
OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject
*iface
)
690 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
691 FIXME("(%p)\n", This
);
695 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl
=
697 OleInPlaceObject_QueryInterface
,
698 OleInPlaceObject_AddRef
,
699 OleInPlaceObject_Release
,
700 OleInPlaceObject_GetWindow
,
701 OleInPlaceObject_ContextSensitiveHelp
,
702 OleInPlaceObject_InPlaceDeactivate
,
703 OleInPlaceObject_UIDeactivate
,
704 OleInPlaceObject_SetObjectRects
,
705 OleInPlaceObject_ReactivateAndUndo
708 /**********************************************************************
709 * Implement the IOleControl interface
712 static inline WebBrowser
*impl_from_IOleControl(IOleControl
*iface
)
714 return CONTAINING_RECORD(iface
, WebBrowser
, IOleControl_iface
);
717 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
,
718 REFIID riid
, LPVOID
*ppobj
)
720 WebBrowser
*This
= impl_from_IOleControl(iface
);
721 return IWebBrowser_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
724 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
726 WebBrowser
*This
= impl_from_IOleControl(iface
);
727 return IWebBrowser_AddRef(&This
->IWebBrowser2_iface
);
730 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
732 WebBrowser
*This
= impl_from_IOleControl(iface
);
733 return IWebBrowser_Release(&This
->IWebBrowser2_iface
);
736 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, LPCONTROLINFO pCI
)
738 WebBrowser
*This
= impl_from_IOleControl(iface
);
740 TRACE("(%p)->(%p)\n", This
, pCI
);
742 /* Tests show that this function should be not implemented */
746 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, struct tagMSG
*pMsg
)
748 WebBrowser
*This
= impl_from_IOleControl(iface
);
749 FIXME("(%p)->(%p)\n", This
, pMsg
);
753 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
755 WebBrowser
*This
= impl_from_IOleControl(iface
);
757 TRACE("(%p)->(%d)\n", This
, dispID
);
761 /* Unknown means multiple properties changed, so check them all.
762 * BUT the Webbrowser OleControl object doesn't appear to do this.
765 case DISPID_AMBIENT_DLCONTROL
:
767 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
768 return on_offlineconnected_change(This
);
769 case DISPID_AMBIENT_SILENT
:
770 return on_silent_change(This
);
773 FIXME("Unknown dispID %d\n", dispID
);
777 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
779 WebBrowser
*This
= impl_from_IOleControl(iface
);
780 FIXME("(%p)->(%x)\n", This
, bFreeze
);
784 static const IOleControlVtbl OleControlVtbl
=
786 OleControl_QueryInterface
,
789 OleControl_GetControlInfo
,
790 OleControl_OnMnemonic
,
791 OleControl_OnAmbientPropertyChange
,
792 OleControl_FreezeEvents
795 static inline WebBrowser
*impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject
*iface
)
797 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceActiveObject_iface
);
800 static HRESULT WINAPI
InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject
*iface
,
801 REFIID riid
, void **ppv
)
803 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
804 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
807 static ULONG WINAPI
InPlaceActiveObject_AddRef(IOleInPlaceActiveObject
*iface
)
809 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
810 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
813 static ULONG WINAPI
InPlaceActiveObject_Release(IOleInPlaceActiveObject
*iface
)
815 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
816 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
819 static HRESULT WINAPI
InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject
*iface
,
822 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
823 return IOleInPlaceObject_GetWindow(&This
->IOleInPlaceObject_iface
, phwnd
);
826 static HRESULT WINAPI
InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject
*iface
,
829 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
830 return IOleInPlaceObject_ContextSensitiveHelp(&This
->IOleInPlaceObject_iface
, fEnterMode
);
833 static HRESULT WINAPI
InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject
*iface
,
836 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
837 IOleInPlaceActiveObject
*activeobj
;
838 HRESULT hr
= S_FALSE
;
840 TRACE("(%p)->(%p)\n", This
, lpmsg
);
842 if(This
->doc_host
.document
) {
843 if(SUCCEEDED(IUnknown_QueryInterface(This
->doc_host
.document
,
844 &IID_IOleInPlaceActiveObject
,
845 (void**)&activeobj
))) {
846 hr
= IOleInPlaceActiveObject_TranslateAccelerator(activeobj
, lpmsg
);
847 IOleInPlaceActiveObject_Release(activeobj
);
857 static HRESULT WINAPI
InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject
*iface
,
860 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
861 FIXME("(%p)->(%x)\n", This
, fActivate
);
865 static HRESULT WINAPI
InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject
*iface
,
868 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
869 FIXME("(%p)->(%x)\n", This
, fActivate
);
873 static HRESULT WINAPI
InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject
*iface
,
874 LPCRECT lprcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fFrameWindow
)
876 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
877 FIXME("(%p)->(%p %p %x)\n", This
, lprcBorder
, pUIWindow
, fFrameWindow
);
881 static HRESULT WINAPI
InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject
*iface
,
884 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
885 FIXME("(%p)->(%x)\n", This
, fEnable
);
889 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl
= {
890 InPlaceActiveObject_QueryInterface
,
891 InPlaceActiveObject_AddRef
,
892 InPlaceActiveObject_Release
,
893 InPlaceActiveObject_GetWindow
,
894 InPlaceActiveObject_ContextSensitiveHelp
,
895 InPlaceActiveObject_TranslateAccelerator
,
896 InPlaceActiveObject_OnFrameWindowActivate
,
897 InPlaceActiveObject_OnDocWindowActivate
,
898 InPlaceActiveObject_ResizeBorder
,
899 InPlaceActiveObject_EnableModeless
902 static inline WebBrowser
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
904 return CONTAINING_RECORD(iface
, WebBrowser
, IOleCommandTarget_iface
);
907 static HRESULT WINAPI
WBOleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
908 REFIID riid
, void **ppv
)
910 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
911 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
914 static ULONG WINAPI
WBOleCommandTarget_AddRef(IOleCommandTarget
*iface
)
916 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
917 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
920 static ULONG WINAPI
WBOleCommandTarget_Release(IOleCommandTarget
*iface
)
922 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
923 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
926 static HRESULT WINAPI
WBOleCommandTarget_QueryStatus(IOleCommandTarget
*iface
,
927 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
929 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
930 IOleCommandTarget
*cmdtrg
;
933 TRACE("(%p)->(%s %u %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
,
936 if(!This
->doc_host
.document
)
939 /* NOTE: There are probably some commands that we should handle here
940 * instead of forwarding to document object. */
942 hres
= IUnknown_QueryInterface(This
->doc_host
.document
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
946 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
947 IOleCommandTarget_Release(cmdtrg
);
952 static HRESULT WINAPI
WBOleCommandTarget_Exec(IOleCommandTarget
*iface
,
953 const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
,
956 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
957 FIXME("(%p)->(%s %d %d %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
,
958 nCmdexecopt
, pvaIn
, pvaOut
);
962 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
963 WBOleCommandTarget_QueryInterface
,
964 WBOleCommandTarget_AddRef
,
965 WBOleCommandTarget_Release
,
966 WBOleCommandTarget_QueryStatus
,
967 WBOleCommandTarget_Exec
970 void WebBrowser_OleObject_Init(WebBrowser
*This
)
976 /* default aspect ratio is 96dpi / 96dpi */
978 dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
979 dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
982 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
983 This
->IOleInPlaceObject_iface
.lpVtbl
= &OleInPlaceObjectVtbl
;
984 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
985 This
->IOleInPlaceActiveObject_iface
.lpVtbl
= &OleInPlaceActiveObjectVtbl
;
986 This
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
988 /* Default size is 50x20 pixels, in himetric units */
989 This
->extent
.cx
= MulDiv( 50, 2540, dpi_x
);
990 This
->extent
.cy
= MulDiv( 20, 2540, dpi_y
);
993 void WebBrowser_OleObject_Destroy(WebBrowser
*This
)
995 release_client_site(This
);