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(ieframe
);
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
);
138 This
->inplace
= NULL
;
142 hres
= IOleInPlaceSite_GetWindow(This
->inplace
, &parent_hwnd
);
144 SHSetParentHwnd(This
->shell_embedding_hwnd
, parent_hwnd
);
146 IOleInPlaceSite_OnInPlaceActivate(This
->inplace
);
148 This
->frameinfo
.cb
= sizeof(OLEINPLACEFRAMEINFO
);
149 IOleInPlaceSite_GetWindowContext(This
->inplace
, &This
->doc_host
.frame
, &This
->uiwindow
,
150 &This
->pos_rect
, &This
->clip_rect
,
153 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
154 This
->pos_rect
.left
, This
->pos_rect
.top
,
155 This
->pos_rect
.right
-This
->pos_rect
.left
,
156 This
->pos_rect
.bottom
-This
->pos_rect
.top
,
157 SWP_NOZORDER
| SWP_SHOWWINDOW
);
160 IOleContainer
*container
;
162 IOleClientSite_ShowObject(This
->client
);
164 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
165 if(SUCCEEDED(hres
)) {
167 IOleContainer_Release(This
->container
);
168 This
->container
= container
;
172 if(This
->doc_host
.frame
)
173 IOleInPlaceFrame_GetWindow(This
->doc_host
.frame
, &This
->frame_hwnd
);
178 static HRESULT
activate_ui(WebBrowser
*This
, IOleClientSite
*active_site
)
182 static const WCHAR wszitem
[] = {'i','t','e','m',0};
186 if(This
->shell_embedding_hwnd
)
187 ShowWindow(This
->shell_embedding_hwnd
, SW_SHOW
);
191 hres
= activate_inplace(This
, active_site
);
195 IOleInPlaceSite_OnUIActivate(This
->inplace
);
197 if(This
->doc_host
.frame
)
198 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
200 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
202 if(This
->doc_host
.frame
)
203 IOleInPlaceFrame_SetMenu(This
->doc_host
.frame
, NULL
, NULL
, This
->shell_embedding_hwnd
);
205 SetFocus(This
->shell_embedding_hwnd
);
210 static HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
212 IDispatch
*disp
= NULL
;
213 DISPPARAMS dispparams
= {NULL
, 0};
221 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
223 TRACE("Could not get IDispatch\n");
227 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
228 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, NULL
);
230 IDispatch_Release(disp
);
235 static HRESULT
on_offlineconnected_change(WebBrowser
*This
)
239 get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
241 if(V_VT(&offline
) == VT_BOOL
)
242 IWebBrowser2_put_Offline(&This
->IWebBrowser2_iface
, V_BOOL(&offline
));
243 else if(V_VT(&offline
) != VT_EMPTY
)
244 WARN("wrong V_VT(silent) %d\n", V_VT(&offline
));
249 static HRESULT
on_silent_change(WebBrowser
*This
)
253 get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
255 if(V_VT(&silent
) == VT_BOOL
)
256 IWebBrowser2_put_Silent(&This
->IWebBrowser2_iface
, V_BOOL(&silent
));
257 else if(V_VT(&silent
) != VT_EMPTY
)
258 WARN("wrong V_VT(silent) %d\n", V_VT(&silent
));
263 static void release_client_site(WebBrowser
*This
)
265 release_dochost_client(&This
->doc_host
);
267 if(This
->shell_embedding_hwnd
) {
268 DestroyWindow(This
->shell_embedding_hwnd
);
269 This
->shell_embedding_hwnd
= NULL
;
273 IOleInPlaceSite_Release(This
->inplace
);
274 This
->inplace
= NULL
;
277 if(This
->container
) {
278 IOleContainer_Release(This
->container
);
279 This
->container
= NULL
;
283 IOleInPlaceUIWindow_Release(This
->uiwindow
);
284 This
->uiwindow
= NULL
;
288 IOleClientSite_Release(This
->client
);
294 IEnumOLEVERB IEnumOLEVERB_iface
;
299 static inline EnumOLEVERB
*impl_from_IEnumOLEVERB(IEnumOLEVERB
*iface
)
301 return CONTAINING_RECORD(iface
, EnumOLEVERB
, IEnumOLEVERB_iface
);
304 static HRESULT WINAPI
EnumOLEVERB_QueryInterface(IEnumOLEVERB
*iface
, REFIID riid
, void **ppv
)
306 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
308 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
309 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
310 *ppv
= &This
->IEnumOLEVERB_iface
;
311 }else if(IsEqualGUID(&IID_IEnumOLEVERB
, riid
)) {
312 TRACE("(%p)->(IID_IEnumOLEVERB %p)\n", This
, ppv
);
313 *ppv
= &This
->IEnumOLEVERB_iface
;
315 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
317 return E_NOINTERFACE
;
320 IUnknown_AddRef((IUnknown
*)*ppv
);
324 static ULONG WINAPI
EnumOLEVERB_AddRef(IEnumOLEVERB
*iface
)
326 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
327 LONG ref
= InterlockedIncrement(&This
->ref
);
329 TRACE("(%p) ref=%d\n", This
, ref
);
334 static ULONG WINAPI
EnumOLEVERB_Release(IEnumOLEVERB
*iface
)
336 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
337 LONG ref
= InterlockedDecrement(&This
->ref
);
339 TRACE("(%p) ref=%d\n", This
, ref
);
347 static HRESULT WINAPI
EnumOLEVERB_Next(IEnumOLEVERB
*iface
, ULONG celt
, OLEVERB
*rgelt
, ULONG
*pceltFetched
)
349 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
351 TRACE("(%p)->(%u %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
358 static HRESULT WINAPI
EnumOLEVERB_Skip(IEnumOLEVERB
*iface
, ULONG celt
)
360 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
361 TRACE("(%p)->(%u)\n", This
, celt
);
365 static HRESULT WINAPI
EnumOLEVERB_Reset(IEnumOLEVERB
*iface
)
367 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
368 TRACE("(%p)\n", This
);
372 static HRESULT WINAPI
EnumOLEVERB_Clone(IEnumOLEVERB
*iface
, IEnumOLEVERB
**ppenum
)
374 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
375 FIXME("(%p)->(%p)\n", This
, ppenum
);
379 static const IEnumOLEVERBVtbl EnumOLEVERBVtbl
= {
380 EnumOLEVERB_QueryInterface
,
389 /**********************************************************************
390 * Implement the IOleObject interface for the WebBrowser control
393 static inline WebBrowser
*impl_from_IOleObject(IOleObject
*iface
)
395 return CONTAINING_RECORD(iface
, WebBrowser
, IOleObject_iface
);
398 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
400 WebBrowser
*This
= impl_from_IOleObject(iface
);
401 return IWebBrowser_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
404 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
406 WebBrowser
*This
= impl_from_IOleObject(iface
);
407 return IWebBrowser_AddRef(&This
->IWebBrowser2_iface
);
410 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
412 WebBrowser
*This
= impl_from_IOleObject(iface
);
413 return IWebBrowser_Release(&This
->IWebBrowser2_iface
);
416 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, LPOLECLIENTSITE pClientSite
)
418 WebBrowser
*This
= impl_from_IOleObject(iface
);
419 IDocHostUIHandler
*hostui
;
420 IOleContainer
*container
;
424 TRACE("(%p)->(%p)\n", This
, pClientSite
);
426 if(This
->client
== pClientSite
)
429 release_client_site(This
);
432 if(This
->doc_host
.document
)
433 deactivate_document(&This
->doc_host
);
437 IOleClientSite_AddRef(pClientSite
);
438 This
->client
= pClientSite
;
440 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDispatch
,
443 This
->doc_host
.client_disp
= disp
;
445 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
,
448 This
->doc_host
.hostui
= hostui
;
450 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
451 if(SUCCEEDED(hres
)) {
452 ITargetContainer
*target_container
;
454 hres
= IOleContainer_QueryInterface(container
, &IID_ITargetContainer
,
455 (void**)&target_container
);
456 if(SUCCEEDED(hres
)) {
457 FIXME("Unsupported ITargetContainer\n");
458 ITargetContainer_Release(target_container
);
461 IOleContainer_Release(container
);
464 create_shell_embedding_hwnd(This
);
466 on_offlineconnected_change(This
);
467 on_silent_change(This
);
472 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, LPOLECLIENTSITE
*ppClientSite
)
474 WebBrowser
*This
= impl_from_IOleObject(iface
);
476 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
482 IOleClientSite_AddRef(This
->client
);
483 *ppClientSite
= This
->client
;
488 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
,
489 LPCOLESTR szContainerObj
)
491 WebBrowser
*This
= impl_from_IOleObject(iface
);
493 TRACE("(%p)->(%s, %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
495 /* We have nothing to do here. */
499 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
501 WebBrowser
*This
= impl_from_IOleObject(iface
);
503 TRACE("(%p)->(%d)\n", This
, dwSaveOption
);
505 if(dwSaveOption
!= OLECLOSE_NOSAVE
) {
506 FIXME("unimplemented flag: %x\n", dwSaveOption
);
510 if(This
->doc_host
.frame
)
511 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, NULL
, NULL
);
514 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, NULL
, NULL
);
517 IOleInPlaceSite_OnUIDeactivate(This
->inplace
, FALSE
);
518 IOleInPlaceSite_OnInPlaceDeactivate(This
->inplace
);
521 return IOleObject_SetClientSite(iface
, NULL
);
524 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
* pmk
)
526 WebBrowser
*This
= impl_from_IOleObject(iface
);
527 FIXME("(%p)->(%d, %p)\n", This
, dwWhichMoniker
, pmk
);
531 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
,
532 DWORD dwWhichMoniker
, LPMONIKER
*ppmk
)
534 WebBrowser
*This
= impl_from_IOleObject(iface
);
535 FIXME("(%p)->(%d, %d, %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
539 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, LPDATAOBJECT pDataObject
,
540 BOOL fCreation
, DWORD dwReserved
)
542 WebBrowser
*This
= impl_from_IOleObject(iface
);
543 FIXME("(%p)->(%p, %d, %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
547 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
,
548 LPDATAOBJECT
*ppDataObject
)
550 WebBrowser
*This
= impl_from_IOleObject(iface
);
551 FIXME("(%p)->(%d, %p)\n", This
, dwReserved
, ppDataObject
);
555 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, struct tagMSG
* lpmsg
,
556 LPOLECLIENTSITE pActiveSite
, LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
558 WebBrowser
*This
= impl_from_IOleObject(iface
);
560 TRACE("(%p)->(%d %p %p %d %p %p)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
,
566 TRACE("OLEIVERB_SHOW\n");
567 return activate_ui(This
, pActiveSite
);
568 case OLEIVERB_UIACTIVATE
:
569 TRACE("OLEIVERB_UIACTIVATE\n");
570 return activate_ui(This
, pActiveSite
);
571 case OLEIVERB_INPLACEACTIVATE
:
572 TRACE("OLEIVERB_INPLACEACTIVATE\n");
573 return activate_inplace(This
, pActiveSite
);
575 TRACE("OLEIVERB_HIDE\n");
576 if(This
->shell_embedding_hwnd
)
577 ShowWindow(This
->shell_embedding_hwnd
, SW_HIDE
);
580 FIXME("stub for %d\n", iVerb
);
587 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
589 WebBrowser
*This
= impl_from_IOleObject(iface
);
592 TRACE("(%p)->(%p)\n", This
, ppEnumOleVerb
);
594 ret
= heap_alloc(sizeof(*ret
));
596 return E_OUTOFMEMORY
;
598 ret
->IEnumOLEVERB_iface
.lpVtbl
= &EnumOLEVERBVtbl
;
601 *ppEnumOleVerb
= &ret
->IEnumOLEVERB_iface
;
605 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
607 WebBrowser
*This
= impl_from_IOleObject(iface
);
608 FIXME("(%p)\n", This
);
612 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
614 WebBrowser
*This
= impl_from_IOleObject(iface
);
615 FIXME("(%p)\n", This
);
619 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
* pClsid
)
621 WebBrowser
*This
= impl_from_IOleObject(iface
);
622 FIXME("(%p)->(%p)\n", This
, pClsid
);
626 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
,
627 LPOLESTR
* pszUserType
)
629 WebBrowser
*This
= impl_from_IOleObject(iface
);
630 TRACE("(%p, %d, %p)\n", This
, dwFormOfType
, pszUserType
);
631 return OleRegGetUserType(&CLSID_WebBrowser
, dwFormOfType
, pszUserType
);
634 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
636 WebBrowser
*This
= impl_from_IOleObject(iface
);
638 TRACE("(%p)->(%x %p)\n", This
, dwDrawAspect
, psizel
);
640 /* Tests show that dwDrawAspect is ignored */
641 This
->extent
= *psizel
;
645 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
647 WebBrowser
*This
= impl_from_IOleObject(iface
);
649 TRACE("(%p)->(%x, %p)\n", This
, dwDrawAspect
, psizel
);
651 /* Tests show that dwDrawAspect is ignored */
652 *psizel
= This
->extent
;
656 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
,
657 DWORD
* pdwConnection
)
659 WebBrowser
*This
= impl_from_IOleObject(iface
);
660 FIXME("(%p)->(%p, %p)\n", This
, pAdvSink
, pdwConnection
);
664 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
666 WebBrowser
*This
= impl_from_IOleObject(iface
);
667 FIXME("(%p)->(%d)\n", This
, dwConnection
);
671 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
673 WebBrowser
*This
= impl_from_IOleObject(iface
);
674 FIXME("(%p)->(%p)\n", This
, ppenumAdvise
);
678 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
680 WebBrowser
*This
= impl_from_IOleObject(iface
);
682 TRACE("(%p)->(%x, %p)\n", This
, dwAspect
, pdwStatus
);
684 *pdwStatus
= OLEMISC_SETCLIENTSITEFIRST
|OLEMISC_ACTIVATEWHENVISIBLE
|OLEMISC_INSIDEOUT
685 |OLEMISC_CANTLINKINSIDE
|OLEMISC_RECOMPOSEONRESIZE
;
690 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
* pLogpal
)
692 WebBrowser
*This
= impl_from_IOleObject(iface
);
693 FIXME("(%p)->(%p)\n", This
, pLogpal
);
697 static const IOleObjectVtbl OleObjectVtbl
=
699 OleObject_QueryInterface
,
702 OleObject_SetClientSite
,
703 OleObject_GetClientSite
,
704 OleObject_SetHostNames
,
706 OleObject_SetMoniker
,
707 OleObject_GetMoniker
,
708 OleObject_InitFromData
,
709 OleObject_GetClipboardData
,
713 OleObject_IsUpToDate
,
714 OleObject_GetUserClassID
,
715 OleObject_GetUserType
,
720 OleObject_EnumAdvise
,
721 OleObject_GetMiscStatus
,
722 OleObject_SetColorScheme
725 /**********************************************************************
726 * Implement the IOleInPlaceObject interface
729 static inline WebBrowser
*impl_from_IOleInPlaceObject(IOleInPlaceObject
*iface
)
731 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceObject_iface
);
734 static HRESULT WINAPI
OleInPlaceObject_QueryInterface(IOleInPlaceObject
*iface
,
735 REFIID riid
, LPVOID
*ppobj
)
737 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
738 return IWebBrowser_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
741 static ULONG WINAPI
OleInPlaceObject_AddRef(IOleInPlaceObject
*iface
)
743 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
744 return IWebBrowser_AddRef(&This
->IWebBrowser2_iface
);
747 static ULONG WINAPI
OleInPlaceObject_Release(IOleInPlaceObject
*iface
)
749 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
750 return IWebBrowser_Release(&This
->IWebBrowser2_iface
);
753 static HRESULT WINAPI
OleInPlaceObject_GetWindow(IOleInPlaceObject
*iface
, HWND
* phwnd
)
755 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
757 TRACE("(%p)->(%p)\n", This
, phwnd
);
759 *phwnd
= This
->shell_embedding_hwnd
;
763 static HRESULT WINAPI
OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject
*iface
,
766 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
767 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
771 static HRESULT WINAPI
OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject
*iface
)
773 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
774 FIXME("(%p)\n", This
);
777 IOleInPlaceSite_Release(This
->inplace
);
778 This
->inplace
= NULL
;
784 static HRESULT WINAPI
OleInPlaceObject_UIDeactivate(IOleInPlaceObject
*iface
)
786 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
787 FIXME("(%p)\n", This
);
791 static HRESULT WINAPI
OleInPlaceObject_SetObjectRects(IOleInPlaceObject
*iface
,
792 LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
794 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
796 TRACE("(%p)->(%p %p)\n", This
, lprcPosRect
, lprcClipRect
);
798 This
->pos_rect
= *lprcPosRect
;
801 This
->clip_rect
= *lprcClipRect
;
803 if(This
->shell_embedding_hwnd
) {
804 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
805 lprcPosRect
->left
, lprcPosRect
->top
,
806 lprcPosRect
->right
-lprcPosRect
->left
,
807 lprcPosRect
->bottom
-lprcPosRect
->top
,
808 SWP_NOZORDER
| SWP_NOACTIVATE
);
814 static HRESULT WINAPI
OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject
*iface
)
816 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
817 FIXME("(%p)\n", This
);
821 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl
=
823 OleInPlaceObject_QueryInterface
,
824 OleInPlaceObject_AddRef
,
825 OleInPlaceObject_Release
,
826 OleInPlaceObject_GetWindow
,
827 OleInPlaceObject_ContextSensitiveHelp
,
828 OleInPlaceObject_InPlaceDeactivate
,
829 OleInPlaceObject_UIDeactivate
,
830 OleInPlaceObject_SetObjectRects
,
831 OleInPlaceObject_ReactivateAndUndo
834 /**********************************************************************
835 * Implement the IOleControl interface
838 static inline WebBrowser
*impl_from_IOleControl(IOleControl
*iface
)
840 return CONTAINING_RECORD(iface
, WebBrowser
, IOleControl_iface
);
843 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
,
844 REFIID riid
, LPVOID
*ppobj
)
846 WebBrowser
*This
= impl_from_IOleControl(iface
);
847 return IWebBrowser_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
850 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
852 WebBrowser
*This
= impl_from_IOleControl(iface
);
853 return IWebBrowser_AddRef(&This
->IWebBrowser2_iface
);
856 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
858 WebBrowser
*This
= impl_from_IOleControl(iface
);
859 return IWebBrowser_Release(&This
->IWebBrowser2_iface
);
862 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, LPCONTROLINFO pCI
)
864 WebBrowser
*This
= impl_from_IOleControl(iface
);
866 TRACE("(%p)->(%p)\n", This
, pCI
);
868 /* Tests show that this function should be not implemented */
872 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, struct tagMSG
*pMsg
)
874 WebBrowser
*This
= impl_from_IOleControl(iface
);
875 FIXME("(%p)->(%p)\n", This
, pMsg
);
879 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
881 WebBrowser
*This
= impl_from_IOleControl(iface
);
883 TRACE("(%p)->(%d)\n", This
, dispID
);
887 /* Unknown means multiple properties changed, so check them all.
888 * BUT the Webbrowser OleControl object doesn't appear to do this.
891 case DISPID_AMBIENT_DLCONTROL
:
893 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
894 return on_offlineconnected_change(This
);
895 case DISPID_AMBIENT_SILENT
:
896 return on_silent_change(This
);
899 FIXME("Unknown dispID %d\n", dispID
);
903 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
905 WebBrowser
*This
= impl_from_IOleControl(iface
);
906 FIXME("(%p)->(%x)\n", This
, bFreeze
);
910 static const IOleControlVtbl OleControlVtbl
=
912 OleControl_QueryInterface
,
915 OleControl_GetControlInfo
,
916 OleControl_OnMnemonic
,
917 OleControl_OnAmbientPropertyChange
,
918 OleControl_FreezeEvents
921 static inline WebBrowser
*impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject
*iface
)
923 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceActiveObject_iface
);
926 static HRESULT WINAPI
InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject
*iface
,
927 REFIID riid
, void **ppv
)
929 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
930 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
933 static ULONG WINAPI
InPlaceActiveObject_AddRef(IOleInPlaceActiveObject
*iface
)
935 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
936 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
939 static ULONG WINAPI
InPlaceActiveObject_Release(IOleInPlaceActiveObject
*iface
)
941 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
942 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
945 static HRESULT WINAPI
InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject
*iface
,
948 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
949 return IOleInPlaceObject_GetWindow(&This
->IOleInPlaceObject_iface
, phwnd
);
952 static HRESULT WINAPI
InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject
*iface
,
955 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
956 return IOleInPlaceObject_ContextSensitiveHelp(&This
->IOleInPlaceObject_iface
, fEnterMode
);
959 static HRESULT WINAPI
InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject
*iface
,
962 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
963 IOleInPlaceActiveObject
*activeobj
;
964 HRESULT hr
= S_FALSE
;
966 TRACE("(%p)->(%p)\n", This
, lpmsg
);
968 if(This
->doc_host
.document
) {
969 if(SUCCEEDED(IUnknown_QueryInterface(This
->doc_host
.document
,
970 &IID_IOleInPlaceActiveObject
,
971 (void**)&activeobj
))) {
972 hr
= IOleInPlaceActiveObject_TranslateAccelerator(activeobj
, lpmsg
);
973 IOleInPlaceActiveObject_Release(activeobj
);
983 static HRESULT WINAPI
InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject
*iface
,
986 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
987 FIXME("(%p)->(%x)\n", This
, fActivate
);
991 static HRESULT WINAPI
InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject
*iface
,
994 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
995 FIXME("(%p)->(%x)\n", This
, fActivate
);
999 static HRESULT WINAPI
InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject
*iface
,
1000 LPCRECT lprcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fFrameWindow
)
1002 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1003 FIXME("(%p)->(%p %p %x)\n", This
, lprcBorder
, pUIWindow
, fFrameWindow
);
1007 static HRESULT WINAPI
InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject
*iface
,
1010 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1011 FIXME("(%p)->(%x)\n", This
, fEnable
);
1015 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl
= {
1016 InPlaceActiveObject_QueryInterface
,
1017 InPlaceActiveObject_AddRef
,
1018 InPlaceActiveObject_Release
,
1019 InPlaceActiveObject_GetWindow
,
1020 InPlaceActiveObject_ContextSensitiveHelp
,
1021 InPlaceActiveObject_TranslateAccelerator
,
1022 InPlaceActiveObject_OnFrameWindowActivate
,
1023 InPlaceActiveObject_OnDocWindowActivate
,
1024 InPlaceActiveObject_ResizeBorder
,
1025 InPlaceActiveObject_EnableModeless
1028 static inline WebBrowser
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
1030 return CONTAINING_RECORD(iface
, WebBrowser
, IOleCommandTarget_iface
);
1033 static HRESULT WINAPI
WBOleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
1034 REFIID riid
, void **ppv
)
1036 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1037 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
1040 static ULONG WINAPI
WBOleCommandTarget_AddRef(IOleCommandTarget
*iface
)
1042 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1043 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
1046 static ULONG WINAPI
WBOleCommandTarget_Release(IOleCommandTarget
*iface
)
1048 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1049 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
1052 static HRESULT WINAPI
WBOleCommandTarget_QueryStatus(IOleCommandTarget
*iface
,
1053 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
1055 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1056 IOleCommandTarget
*cmdtrg
;
1059 TRACE("(%p)->(%s %u %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
,
1062 if(!This
->doc_host
.document
)
1065 /* NOTE: There are probably some commands that we should handle here
1066 * instead of forwarding to document object. */
1068 hres
= IUnknown_QueryInterface(This
->doc_host
.document
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1072 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
1073 IOleCommandTarget_Release(cmdtrg
);
1078 static HRESULT WINAPI
WBOleCommandTarget_Exec(IOleCommandTarget
*iface
,
1079 const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
,
1082 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1083 FIXME("(%p)->(%s %d %d %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
,
1084 nCmdexecopt
, pvaIn
, pvaOut
);
1088 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
1089 WBOleCommandTarget_QueryInterface
,
1090 WBOleCommandTarget_AddRef
,
1091 WBOleCommandTarget_Release
,
1092 WBOleCommandTarget_QueryStatus
,
1093 WBOleCommandTarget_Exec
1096 void WebBrowser_OleObject_Init(WebBrowser
*This
)
1102 /* default aspect ratio is 96dpi / 96dpi */
1104 dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
1105 dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
1108 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1109 This
->IOleInPlaceObject_iface
.lpVtbl
= &OleInPlaceObjectVtbl
;
1110 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1111 This
->IOleInPlaceActiveObject_iface
.lpVtbl
= &OleInPlaceActiveObjectVtbl
;
1112 This
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
1114 /* Default size is 50x20 pixels, in himetric units */
1115 This
->extent
.cx
= MulDiv( 50, 2540, dpi_x
);
1116 This
->extent
.cy
= MulDiv( 20, 2540, dpi_y
);
1119 void WebBrowser_OleObject_Destroy(WebBrowser
*This
)
1121 release_client_site(This
);