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
29 HWND WINAPI
SHSetParentHwnd(HWND hWnd
, HWND hWndParent
);
31 static ATOM shell_embedding_atom
= 0;
33 static LRESULT
resize_window(WebBrowser
*This
, LONG width
, LONG height
)
35 if(This
->doc_host
.hwnd
)
36 SetWindowPos(This
->doc_host
.hwnd
, NULL
, 0, 0, width
, height
,
37 SWP_NOZORDER
| SWP_NOACTIVATE
);
42 static LRESULT WINAPI
shell_embedding_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
46 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
48 if(msg
== WM_CREATE
) {
49 This
= *(WebBrowser
**)lParam
;
50 SetPropW(hwnd
, wszTHIS
, This
);
52 This
= GetPropW(hwnd
, wszTHIS
);
57 return resize_window(This
, LOWORD(lParam
), HIWORD(lParam
));
59 return process_dochost_tasks(&This
->doc_host
);
62 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
65 static void create_shell_embedding_hwnd(WebBrowser
*This
)
67 IOleInPlaceSite
*inplace
;
71 static const WCHAR wszShellEmbedding
[] =
72 {'S','h','e','l','l',' ','E','m','b','e','d','d','i','n','g',0};
74 if(!shell_embedding_atom
) {
75 static WNDCLASSEXW wndclass
= {
79 0, 0 /* native uses 8 */, NULL
, NULL
, NULL
,
80 (HBRUSH
)(COLOR_WINDOW
+ 1), NULL
,
84 wndclass
.hInstance
= ieframe_instance
;
86 RegisterClassExW(&wndclass
);
89 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleInPlaceSite
, (void**)&inplace
);
91 IOleInPlaceSite_GetWindow(inplace
, &parent
);
92 IOleInPlaceSite_Release(inplace
);
95 This
->doc_host
.frame_hwnd
= This
->shell_embedding_hwnd
= CreateWindowExW(
97 wszShellEmbedding
, wszShellEmbedding
,
98 WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
99 | (parent
? WS_CHILD
| WS_TABSTOP
: WS_POPUP
| WS_MAXIMIZEBOX
),
101 NULL
, ieframe_instance
, This
);
103 TRACE("parent=%p hwnd=%p\n", parent
, This
->shell_embedding_hwnd
);
106 static HRESULT
activate_inplace(WebBrowser
*This
, IOleClientSite
*active_site
)
117 hres
= IOleClientSite_QueryInterface(active_site
, &IID_IOleInPlaceSite
,
118 (void**)&This
->inplace
);
120 WARN("Could not get IOleInPlaceSite\n");
124 hres
= IOleInPlaceSiteEx_CanInPlaceActivate(This
->inplace
);
126 WARN("CanInPlaceActivate returned: %08x\n", hres
);
127 IOleInPlaceSiteEx_Release(This
->inplace
);
128 This
->inplace
= NULL
;
132 hres
= IOleInPlaceSiteEx_GetWindow(This
->inplace
, &parent_hwnd
);
134 SHSetParentHwnd(This
->shell_embedding_hwnd
, parent_hwnd
);
136 IOleInPlaceSiteEx_OnInPlaceActivate(This
->inplace
);
138 This
->frameinfo
.cb
= sizeof(OLEINPLACEFRAMEINFO
);
139 IOleInPlaceSiteEx_GetWindowContext(This
->inplace
, &This
->doc_host
.frame
, &This
->uiwindow
,
140 &This
->pos_rect
, &This
->clip_rect
,
143 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
144 This
->pos_rect
.left
, This
->pos_rect
.top
,
145 This
->pos_rect
.right
-This
->pos_rect
.left
,
146 This
->pos_rect
.bottom
-This
->pos_rect
.top
,
147 SWP_NOZORDER
| SWP_SHOWWINDOW
);
150 IOleContainer
*container
;
152 IOleClientSite_ShowObject(This
->client
);
154 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
155 if(SUCCEEDED(hres
)) {
157 IOleContainer_Release(This
->container
);
158 This
->container
= container
;
162 if(This
->doc_host
.frame
)
163 IOleInPlaceFrame_GetWindow(This
->doc_host
.frame
, &This
->frame_hwnd
);
168 static HRESULT
activate_ui(WebBrowser
*This
, IOleClientSite
*active_site
)
172 static const WCHAR wszitem
[] = {'i','t','e','m',0};
176 if(This
->shell_embedding_hwnd
)
177 ShowWindow(This
->shell_embedding_hwnd
, SW_SHOW
);
181 hres
= activate_inplace(This
, active_site
);
185 IOleInPlaceSiteEx_OnUIActivate(This
->inplace
);
187 if(This
->doc_host
.frame
)
188 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
190 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, &This
->IOleInPlaceActiveObject_iface
, wszitem
);
192 if(This
->doc_host
.frame
)
193 IOleInPlaceFrame_SetMenu(This
->doc_host
.frame
, NULL
, NULL
, This
->shell_embedding_hwnd
);
195 SetFocus(This
->shell_embedding_hwnd
);
200 static HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
202 IDispatch
*disp
= NULL
;
203 DISPPARAMS dispparams
= {NULL
, 0};
211 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
213 TRACE("Could not get IDispatch\n");
217 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
218 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, NULL
);
220 IDispatch_Release(disp
);
225 static HRESULT
on_offlineconnected_change(WebBrowser
*This
)
229 get_client_disp_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &offline
);
231 if(V_VT(&offline
) == VT_BOOL
)
232 IWebBrowser2_put_Offline(&This
->IWebBrowser2_iface
, V_BOOL(&offline
));
233 else if(V_VT(&offline
) != VT_EMPTY
)
234 WARN("wrong V_VT(silent) %d\n", V_VT(&offline
));
239 static HRESULT
on_silent_change(WebBrowser
*This
)
243 get_client_disp_property(This
->client
, DISPID_AMBIENT_SILENT
, &silent
);
245 if(V_VT(&silent
) == VT_BOOL
)
246 IWebBrowser2_put_Silent(&This
->IWebBrowser2_iface
, V_BOOL(&silent
));
247 else if(V_VT(&silent
) != VT_EMPTY
)
248 WARN("wrong V_VT(silent) %d\n", V_VT(&silent
));
253 static void release_client_site(WebBrowser
*This
)
255 release_dochost_client(&This
->doc_host
);
257 if(This
->shell_embedding_hwnd
) {
258 DestroyWindow(This
->shell_embedding_hwnd
);
259 This
->shell_embedding_hwnd
= NULL
;
263 IOleInPlaceSiteEx_Release(This
->inplace
);
264 This
->inplace
= NULL
;
267 if(This
->container
) {
268 IOleContainer_Release(This
->container
);
269 This
->container
= NULL
;
273 IOleInPlaceUIWindow_Release(This
->uiwindow
);
274 This
->uiwindow
= NULL
;
278 IOleClientSite_Release(This
->client
);
284 IEnumOLEVERB IEnumOLEVERB_iface
;
289 static inline EnumOLEVERB
*impl_from_IEnumOLEVERB(IEnumOLEVERB
*iface
)
291 return CONTAINING_RECORD(iface
, EnumOLEVERB
, IEnumOLEVERB_iface
);
294 static HRESULT WINAPI
EnumOLEVERB_QueryInterface(IEnumOLEVERB
*iface
, REFIID riid
, void **ppv
)
296 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
298 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
299 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
300 *ppv
= &This
->IEnumOLEVERB_iface
;
301 }else if(IsEqualGUID(&IID_IEnumOLEVERB
, riid
)) {
302 TRACE("(%p)->(IID_IEnumOLEVERB %p)\n", This
, ppv
);
303 *ppv
= &This
->IEnumOLEVERB_iface
;
305 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
307 return E_NOINTERFACE
;
310 IUnknown_AddRef((IUnknown
*)*ppv
);
314 static ULONG WINAPI
EnumOLEVERB_AddRef(IEnumOLEVERB
*iface
)
316 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
317 LONG ref
= InterlockedIncrement(&This
->ref
);
319 TRACE("(%p) ref=%d\n", This
, ref
);
324 static ULONG WINAPI
EnumOLEVERB_Release(IEnumOLEVERB
*iface
)
326 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
327 LONG ref
= InterlockedDecrement(&This
->ref
);
329 TRACE("(%p) ref=%d\n", This
, ref
);
337 static HRESULT WINAPI
EnumOLEVERB_Next(IEnumOLEVERB
*iface
, ULONG celt
, OLEVERB
*rgelt
, ULONG
*pceltFetched
)
339 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
341 TRACE("(%p)->(%u %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
348 static HRESULT WINAPI
EnumOLEVERB_Skip(IEnumOLEVERB
*iface
, ULONG celt
)
350 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
351 TRACE("(%p)->(%u)\n", This
, celt
);
355 static HRESULT WINAPI
EnumOLEVERB_Reset(IEnumOLEVERB
*iface
)
357 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
358 TRACE("(%p)\n", This
);
362 static HRESULT WINAPI
EnumOLEVERB_Clone(IEnumOLEVERB
*iface
, IEnumOLEVERB
**ppenum
)
364 EnumOLEVERB
*This
= impl_from_IEnumOLEVERB(iface
);
365 FIXME("(%p)->(%p)\n", This
, ppenum
);
369 static const IEnumOLEVERBVtbl EnumOLEVERBVtbl
= {
370 EnumOLEVERB_QueryInterface
,
379 /**********************************************************************
380 * Implement the IOleObject interface for the WebBrowser control
383 static inline WebBrowser
*impl_from_IOleObject(IOleObject
*iface
)
385 return CONTAINING_RECORD(iface
, WebBrowser
, IOleObject_iface
);
388 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
390 WebBrowser
*This
= impl_from_IOleObject(iface
);
391 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
394 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
396 WebBrowser
*This
= impl_from_IOleObject(iface
);
397 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
400 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
402 WebBrowser
*This
= impl_from_IOleObject(iface
);
403 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
406 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, LPOLECLIENTSITE pClientSite
)
408 WebBrowser
*This
= impl_from_IOleObject(iface
);
409 IDocHostUIHandler
*hostui
;
410 IOleContainer
*container
;
414 TRACE("(%p)->(%p)\n", This
, pClientSite
);
416 if(This
->client
== pClientSite
)
419 release_client_site(This
);
422 if(This
->doc_host
.document
)
423 deactivate_document(&This
->doc_host
);
427 IOleClientSite_AddRef(pClientSite
);
428 This
->client
= pClientSite
;
430 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDispatch
,
433 This
->doc_host
.client_disp
= disp
;
435 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IDocHostUIHandler
,
438 This
->doc_host
.hostui
= hostui
;
440 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
441 if(SUCCEEDED(hres
)) {
442 ITargetContainer
*target_container
;
444 hres
= IOleContainer_QueryInterface(container
, &IID_ITargetContainer
,
445 (void**)&target_container
);
446 if(SUCCEEDED(hres
)) {
447 FIXME("Unsupported ITargetContainer\n");
448 ITargetContainer_Release(target_container
);
451 IOleContainer_Release(container
);
454 create_shell_embedding_hwnd(This
);
456 on_offlineconnected_change(This
);
457 on_silent_change(This
);
462 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, LPOLECLIENTSITE
*ppClientSite
)
464 WebBrowser
*This
= impl_from_IOleObject(iface
);
466 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
472 IOleClientSite_AddRef(This
->client
);
473 *ppClientSite
= This
->client
;
478 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
,
479 LPCOLESTR szContainerObj
)
481 WebBrowser
*This
= impl_from_IOleObject(iface
);
483 TRACE("(%p)->(%s, %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
485 /* We have nothing to do here. */
489 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
491 WebBrowser
*This
= impl_from_IOleObject(iface
);
493 TRACE("(%p)->(%d)\n", This
, dwSaveOption
);
495 if(dwSaveOption
!= OLECLOSE_NOSAVE
) {
496 FIXME("unimplemented flag: %x\n", dwSaveOption
);
500 if(This
->doc_host
.frame
)
501 IOleInPlaceFrame_SetActiveObject(This
->doc_host
.frame
, NULL
, NULL
);
504 IOleInPlaceUIWindow_SetActiveObject(This
->uiwindow
, NULL
, NULL
);
507 IOleInPlaceSiteEx_OnUIDeactivate(This
->inplace
, FALSE
);
508 IOleInPlaceSiteEx_OnInPlaceDeactivate(This
->inplace
);
511 return IOleObject_SetClientSite(iface
, NULL
);
514 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
* pmk
)
516 WebBrowser
*This
= impl_from_IOleObject(iface
);
517 FIXME("(%p)->(%d, %p)\n", This
, dwWhichMoniker
, pmk
);
521 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
,
522 DWORD dwWhichMoniker
, LPMONIKER
*ppmk
)
524 WebBrowser
*This
= impl_from_IOleObject(iface
);
525 FIXME("(%p)->(%d, %d, %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
529 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, LPDATAOBJECT pDataObject
,
530 BOOL fCreation
, DWORD dwReserved
)
532 WebBrowser
*This
= impl_from_IOleObject(iface
);
533 FIXME("(%p)->(%p, %d, %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
537 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
,
538 LPDATAOBJECT
*ppDataObject
)
540 WebBrowser
*This
= impl_from_IOleObject(iface
);
541 FIXME("(%p)->(%d, %p)\n", This
, dwReserved
, ppDataObject
);
545 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, struct tagMSG
* lpmsg
,
546 LPOLECLIENTSITE pActiveSite
, LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
548 WebBrowser
*This
= impl_from_IOleObject(iface
);
550 TRACE("(%p)->(%d %p %p %d %p %s)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
,
551 wine_dbgstr_rect(lprcPosRect
));
556 TRACE("OLEIVERB_SHOW\n");
557 return activate_ui(This
, pActiveSite
);
558 case OLEIVERB_UIACTIVATE
:
559 TRACE("OLEIVERB_UIACTIVATE\n");
560 return activate_ui(This
, pActiveSite
);
561 case OLEIVERB_INPLACEACTIVATE
:
562 TRACE("OLEIVERB_INPLACEACTIVATE\n");
563 return activate_inplace(This
, pActiveSite
);
565 TRACE("OLEIVERB_HIDE\n");
567 IOleInPlaceSiteEx_OnInPlaceDeactivate(This
->inplace
);
568 if(This
->shell_embedding_hwnd
)
569 ShowWindow(This
->shell_embedding_hwnd
, SW_HIDE
);
572 FIXME("stub for %d\n", iVerb
);
579 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
581 WebBrowser
*This
= impl_from_IOleObject(iface
);
584 TRACE("(%p)->(%p)\n", This
, ppEnumOleVerb
);
586 ret
= heap_alloc(sizeof(*ret
));
588 return E_OUTOFMEMORY
;
590 ret
->IEnumOLEVERB_iface
.lpVtbl
= &EnumOLEVERBVtbl
;
593 *ppEnumOleVerb
= &ret
->IEnumOLEVERB_iface
;
597 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
599 WebBrowser
*This
= impl_from_IOleObject(iface
);
600 FIXME("(%p)\n", This
);
604 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
606 WebBrowser
*This
= impl_from_IOleObject(iface
);
607 FIXME("(%p)\n", This
);
611 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
* pClsid
)
613 WebBrowser
*This
= impl_from_IOleObject(iface
);
614 FIXME("(%p)->(%p)\n", This
, pClsid
);
618 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
,
619 LPOLESTR
* pszUserType
)
621 WebBrowser
*This
= impl_from_IOleObject(iface
);
622 TRACE("(%p, %d, %p)\n", This
, dwFormOfType
, pszUserType
);
623 return OleRegGetUserType(&CLSID_WebBrowser
, dwFormOfType
, pszUserType
);
626 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
628 WebBrowser
*This
= impl_from_IOleObject(iface
);
630 TRACE("(%p)->(%x %p)\n", This
, dwDrawAspect
, psizel
);
632 /* Tests show that dwDrawAspect is ignored */
633 This
->extent
= *psizel
;
637 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
639 WebBrowser
*This
= impl_from_IOleObject(iface
);
641 TRACE("(%p)->(%x, %p)\n", This
, dwDrawAspect
, psizel
);
643 /* Tests show that dwDrawAspect is ignored */
644 *psizel
= This
->extent
;
648 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
,
649 DWORD
* pdwConnection
)
651 WebBrowser
*This
= impl_from_IOleObject(iface
);
652 FIXME("(%p)->(%p, %p)\n", This
, pAdvSink
, pdwConnection
);
656 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
658 WebBrowser
*This
= impl_from_IOleObject(iface
);
659 FIXME("(%p)->(%d)\n", This
, dwConnection
);
663 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
665 WebBrowser
*This
= impl_from_IOleObject(iface
);
666 FIXME("(%p)->(%p)\n", This
, ppenumAdvise
);
670 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
672 WebBrowser
*This
= impl_from_IOleObject(iface
);
674 TRACE("(%p)->(%x, %p)\n", This
, dwAspect
, pdwStatus
);
676 *pdwStatus
= OLEMISC_SETCLIENTSITEFIRST
|OLEMISC_ACTIVATEWHENVISIBLE
|OLEMISC_INSIDEOUT
677 |OLEMISC_CANTLINKINSIDE
|OLEMISC_RECOMPOSEONRESIZE
;
682 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
* pLogpal
)
684 WebBrowser
*This
= impl_from_IOleObject(iface
);
685 FIXME("(%p)->(%p)\n", This
, pLogpal
);
689 static const IOleObjectVtbl OleObjectVtbl
=
691 OleObject_QueryInterface
,
694 OleObject_SetClientSite
,
695 OleObject_GetClientSite
,
696 OleObject_SetHostNames
,
698 OleObject_SetMoniker
,
699 OleObject_GetMoniker
,
700 OleObject_InitFromData
,
701 OleObject_GetClipboardData
,
705 OleObject_IsUpToDate
,
706 OleObject_GetUserClassID
,
707 OleObject_GetUserType
,
712 OleObject_EnumAdvise
,
713 OleObject_GetMiscStatus
,
714 OleObject_SetColorScheme
717 /**********************************************************************
718 * Implement the IOleInPlaceObject interface
721 static inline WebBrowser
*impl_from_IOleInPlaceObject(IOleInPlaceObject
*iface
)
723 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceObject_iface
);
726 static HRESULT WINAPI
OleInPlaceObject_QueryInterface(IOleInPlaceObject
*iface
,
727 REFIID riid
, LPVOID
*ppobj
)
729 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
730 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
733 static ULONG WINAPI
OleInPlaceObject_AddRef(IOleInPlaceObject
*iface
)
735 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
736 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
739 static ULONG WINAPI
OleInPlaceObject_Release(IOleInPlaceObject
*iface
)
741 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
742 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
745 static HRESULT WINAPI
OleInPlaceObject_GetWindow(IOleInPlaceObject
*iface
, HWND
* phwnd
)
747 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
749 TRACE("(%p)->(%p)\n", This
, phwnd
);
751 *phwnd
= This
->shell_embedding_hwnd
;
755 static HRESULT WINAPI
OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObject
*iface
,
758 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
759 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
763 static HRESULT WINAPI
OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObject
*iface
)
765 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
766 FIXME("(%p)\n", This
);
769 IOleInPlaceSiteEx_Release(This
->inplace
);
770 This
->inplace
= NULL
;
776 static HRESULT WINAPI
OleInPlaceObject_UIDeactivate(IOleInPlaceObject
*iface
)
778 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
779 FIXME("(%p)\n", This
);
783 static HRESULT WINAPI
OleInPlaceObject_SetObjectRects(IOleInPlaceObject
*iface
,
784 LPCRECT lprcPosRect
, LPCRECT lprcClipRect
)
786 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
788 TRACE("(%p)->(%p %p)\n", This
, lprcPosRect
, lprcClipRect
);
790 This
->pos_rect
= *lprcPosRect
;
793 This
->clip_rect
= *lprcClipRect
;
795 if(This
->shell_embedding_hwnd
) {
796 SetWindowPos(This
->shell_embedding_hwnd
, NULL
,
797 lprcPosRect
->left
, lprcPosRect
->top
,
798 lprcPosRect
->right
-lprcPosRect
->left
,
799 lprcPosRect
->bottom
-lprcPosRect
->top
,
800 SWP_NOZORDER
| SWP_NOACTIVATE
);
806 static HRESULT WINAPI
OleInPlaceObject_ReactivateAndUndo(IOleInPlaceObject
*iface
)
808 WebBrowser
*This
= impl_from_IOleInPlaceObject(iface
);
809 FIXME("(%p)\n", This
);
813 static const IOleInPlaceObjectVtbl OleInPlaceObjectVtbl
=
815 OleInPlaceObject_QueryInterface
,
816 OleInPlaceObject_AddRef
,
817 OleInPlaceObject_Release
,
818 OleInPlaceObject_GetWindow
,
819 OleInPlaceObject_ContextSensitiveHelp
,
820 OleInPlaceObject_InPlaceDeactivate
,
821 OleInPlaceObject_UIDeactivate
,
822 OleInPlaceObject_SetObjectRects
,
823 OleInPlaceObject_ReactivateAndUndo
826 /**********************************************************************
827 * Implement the IOleControl interface
830 static inline WebBrowser
*impl_from_IOleControl(IOleControl
*iface
)
832 return CONTAINING_RECORD(iface
, WebBrowser
, IOleControl_iface
);
835 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
,
836 REFIID riid
, LPVOID
*ppobj
)
838 WebBrowser
*This
= impl_from_IOleControl(iface
);
839 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppobj
);
842 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
844 WebBrowser
*This
= impl_from_IOleControl(iface
);
845 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
848 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
850 WebBrowser
*This
= impl_from_IOleControl(iface
);
851 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
854 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, LPCONTROLINFO pCI
)
856 WebBrowser
*This
= impl_from_IOleControl(iface
);
858 TRACE("(%p)->(%p)\n", This
, pCI
);
860 /* Tests show that this function should be not implemented */
864 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, struct tagMSG
*pMsg
)
866 WebBrowser
*This
= impl_from_IOleControl(iface
);
867 FIXME("(%p)->(%p)\n", This
, pMsg
);
871 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
873 WebBrowser
*This
= impl_from_IOleControl(iface
);
875 TRACE("(%p)->(%d)\n", This
, dispID
);
879 /* Unknown means multiple properties changed, so check them all.
880 * BUT the Webbrowser OleControl object doesn't appear to do this.
883 case DISPID_AMBIENT_DLCONTROL
:
885 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
886 return on_offlineconnected_change(This
);
887 case DISPID_AMBIENT_SILENT
:
888 return on_silent_change(This
);
891 FIXME("Unknown dispID %d\n", dispID
);
895 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
897 WebBrowser
*This
= impl_from_IOleControl(iface
);
898 FIXME("(%p)->(%x)\n", This
, bFreeze
);
902 static const IOleControlVtbl OleControlVtbl
=
904 OleControl_QueryInterface
,
907 OleControl_GetControlInfo
,
908 OleControl_OnMnemonic
,
909 OleControl_OnAmbientPropertyChange
,
910 OleControl_FreezeEvents
913 static inline WebBrowser
*impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject
*iface
)
915 return CONTAINING_RECORD(iface
, WebBrowser
, IOleInPlaceActiveObject_iface
);
918 static HRESULT WINAPI
InPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject
*iface
,
919 REFIID riid
, void **ppv
)
921 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
922 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
925 static ULONG WINAPI
InPlaceActiveObject_AddRef(IOleInPlaceActiveObject
*iface
)
927 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
928 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
931 static ULONG WINAPI
InPlaceActiveObject_Release(IOleInPlaceActiveObject
*iface
)
933 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
934 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
937 static HRESULT WINAPI
InPlaceActiveObject_GetWindow(IOleInPlaceActiveObject
*iface
,
940 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
941 return IOleInPlaceObject_GetWindow(&This
->IOleInPlaceObject_iface
, phwnd
);
944 static HRESULT WINAPI
InPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject
*iface
,
947 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
948 return IOleInPlaceObject_ContextSensitiveHelp(&This
->IOleInPlaceObject_iface
, fEnterMode
);
951 static HRESULT WINAPI
InPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject
*iface
,
954 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
955 IOleInPlaceActiveObject
*activeobj
;
956 HRESULT hr
= S_FALSE
;
958 TRACE("(%p)->(%p)\n", This
, lpmsg
);
960 if(This
->doc_host
.document
) {
961 if(SUCCEEDED(IUnknown_QueryInterface(This
->doc_host
.document
,
962 &IID_IOleInPlaceActiveObject
,
963 (void**)&activeobj
))) {
964 hr
= IOleInPlaceActiveObject_TranslateAccelerator(activeobj
, lpmsg
);
965 IOleInPlaceActiveObject_Release(activeobj
);
975 static HRESULT WINAPI
InPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject
*iface
,
978 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
979 FIXME("(%p)->(%x)\n", This
, fActivate
);
983 static HRESULT WINAPI
InPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject
*iface
,
986 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
987 FIXME("(%p)->(%x)\n", This
, fActivate
);
991 static HRESULT WINAPI
InPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject
*iface
,
992 LPCRECT lprcBorder
, IOleInPlaceUIWindow
*pUIWindow
, BOOL fFrameWindow
)
994 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
995 FIXME("(%p)->(%p %p %x)\n", This
, lprcBorder
, pUIWindow
, fFrameWindow
);
999 static HRESULT WINAPI
InPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject
*iface
,
1002 WebBrowser
*This
= impl_from_IOleInPlaceActiveObject(iface
);
1003 FIXME("(%p)->(%x)\n", This
, fEnable
);
1007 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl
= {
1008 InPlaceActiveObject_QueryInterface
,
1009 InPlaceActiveObject_AddRef
,
1010 InPlaceActiveObject_Release
,
1011 InPlaceActiveObject_GetWindow
,
1012 InPlaceActiveObject_ContextSensitiveHelp
,
1013 InPlaceActiveObject_TranslateAccelerator
,
1014 InPlaceActiveObject_OnFrameWindowActivate
,
1015 InPlaceActiveObject_OnDocWindowActivate
,
1016 InPlaceActiveObject_ResizeBorder
,
1017 InPlaceActiveObject_EnableModeless
1020 static inline WebBrowser
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
1022 return CONTAINING_RECORD(iface
, WebBrowser
, IOleCommandTarget_iface
);
1025 static HRESULT WINAPI
WBOleCommandTarget_QueryInterface(IOleCommandTarget
*iface
,
1026 REFIID riid
, void **ppv
)
1028 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1029 return IWebBrowser2_QueryInterface(&This
->IWebBrowser2_iface
, riid
, ppv
);
1032 static ULONG WINAPI
WBOleCommandTarget_AddRef(IOleCommandTarget
*iface
)
1034 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1035 return IWebBrowser2_AddRef(&This
->IWebBrowser2_iface
);
1038 static ULONG WINAPI
WBOleCommandTarget_Release(IOleCommandTarget
*iface
)
1040 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1041 return IWebBrowser2_Release(&This
->IWebBrowser2_iface
);
1044 static HRESULT WINAPI
WBOleCommandTarget_QueryStatus(IOleCommandTarget
*iface
,
1045 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
1047 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1048 IOleCommandTarget
*cmdtrg
;
1051 TRACE("(%p)->(%s %u %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
,
1054 if(!This
->doc_host
.document
)
1057 /* NOTE: There are probably some commands that we should handle here
1058 * instead of forwarding to document object. */
1060 hres
= IUnknown_QueryInterface(This
->doc_host
.document
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1064 hres
= IOleCommandTarget_QueryStatus(cmdtrg
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
1065 IOleCommandTarget_Release(cmdtrg
);
1070 static HRESULT WINAPI
WBOleCommandTarget_Exec(IOleCommandTarget
*iface
,
1071 const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
,
1074 WebBrowser
*This
= impl_from_IOleCommandTarget(iface
);
1075 FIXME("(%p)->(%s %d %d %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
,
1076 nCmdexecopt
, pvaIn
, pvaOut
);
1080 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
1081 WBOleCommandTarget_QueryInterface
,
1082 WBOleCommandTarget_AddRef
,
1083 WBOleCommandTarget_Release
,
1084 WBOleCommandTarget_QueryStatus
,
1085 WBOleCommandTarget_Exec
1088 void WebBrowser_OleObject_Init(WebBrowser
*This
)
1094 /* default aspect ratio is 96dpi / 96dpi */
1096 dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
1097 dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
1100 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1101 This
->IOleInPlaceObject_iface
.lpVtbl
= &OleInPlaceObjectVtbl
;
1102 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1103 This
->IOleInPlaceActiveObject_iface
.lpVtbl
= &OleInPlaceActiveObjectVtbl
;
1104 This
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
1106 /* Default size is 50x20 pixels, in himetric units */
1107 This
->extent
.cx
= MulDiv( 50, 2540, dpi_x
);
1108 This
->extent
.cy
= MulDiv( 20, 2540, dpi_y
);
1111 void WebBrowser_OleObject_Destroy(WebBrowser
*This
)
1113 release_client_site(This
);